[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hy
From: |
Jan Kiszka |
Subject: |
Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls |
Date: |
Thu, 20 Sep 2012 09:39:56 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
On 2012-09-20 09:08, David Gibson wrote:
> Currently the KVM exit path for PAPR hypercalls does not synchronize the
> qemu cpu state with the KVM state. Mostly this works, because the actual
> hypercall arguments and return values are explicitly passed through the
> kvm_run structure. However, the hypercall path includes a privilege check,
> to ensure that only the guest kernel can invoke hypercalls, not the guest
> userspace. Because of the lack of sync, this privilege check will use an
> out of date copy of the MSR, which could lead either to guest userspace
> being able to invoke hypercalls (a security hole for the guest) or to the
> guest kernel being incorrectly refused privilege leading to various other
> failures.
>
> This patch fixes the bug by forcing a synchronization on the hypercall exit
> path. This does mean we have a potentially quite expensive get and set of
> the state, however performance critical hypercalls are generally already
> implemented inside KVM so this probably won't matter. If it is a
> performance problem we can optimize it later by having the kernel perform
> the privilege check. That will need a new capability, however, since qemu
> will still need the privilege check for older kernels.
If it's just about reading a small subset of the state (a single MSR?)
to allow the privilege check, you can also open-code only that in HCALL
exit. If it really matters.
Jan
>
> Signed-off-by: David Gibson <address@hidden>
> ---
> target-ppc/kvm.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index 546c116..78a47fb 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -813,6 +813,7 @@ int kvm_arch_handle_exit(CPUPPCState *env, struct kvm_run
> *run)
> #ifdef CONFIG_PSERIES
> case KVM_EXIT_PAPR_HCALL:
> dprintf("handle PAPR hypercall\n");
> + cpu_synchronize_state(env);
> run->papr_hcall.ret = spapr_hypercall(env, run->papr_hcall.nr,
> run->papr_hcall.args);
> ret = 0;
>
--
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
- [Qemu-ppc] [0/2] Bugfixes for ppc KVM, David Gibson, 2012/09/20
- [Qemu-ppc] [PATCH 2/2] target-ppc: KVM: Fix some kernel version edge cases for kvmppc_reset_htab(), David Gibson, 2012/09/20
- [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, David Gibson, 2012/09/20
- Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, Alexander Graf, 2012/09/20
- Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, David Gibson, 2012/09/20
- Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, Alexander Graf, 2012/09/20
- Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, David Gibson, 2012/09/20
- Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, Alexander Graf, 2012/09/24
- Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls, David Gibson, 2012/09/25
Re: [Qemu-ppc] [PATCH 1/2] pseries: Synchronize qemu and KVM state on hypercalls,
Jan Kiszka <=