Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread Jim Mattson
On Mon, Dec 7, 2020 at 3:47 AM stsp wrote: > > 07.12.2020 14:29, Paolo Bonzini пишет: > > On 07/12/20 12:24, stsp wrote: > >> It tries to enable VME among other things. > >> qemu appears to disable VME by default, > >> unless you do "-cpu host". So we have a situation where > >> the host (which

Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread stsp
07.12.2020 17:34, Paolo Bonzini пишет: > It is too late to change that aspect of the API, unfortunately. We > don't know how various userspaces would behave. Which means some sensible behaviour already exists if I don't call KVM_SET_CPUID2. So what is it, #UD on CPUID? I

Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread stsp
07.12.2020 17:09, Paolo Bonzini пишет: Il lun 7 dic 2020, 15:04 stsp > ha scritto: Perhaps it would be good if guest cpuid to have a default values of KVM_GET_SUPPORTED_CPUID, so that the user doesn't have to do the needless calls to just copy host

Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread stsp
07.12.2020 16:35, Paolo Bonzini пишет: Il lun 7 dic 2020, 12:47 stsp > ha scritto: So am I right that KVM_SET_CPUID only "lowers" the supported bits? In which case I don't need to call it at all, but instead just call KVM_GET_SUPPORTED_CPUID and see if

Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread stsp
07.12.2020 14:29, Paolo Bonzini пишет: On 07/12/20 12:24, stsp wrote: It tries to enable VME among other things. qemu appears to disable VME by default, unless you do "-cpu host". So we have a situation where the host (which is qemu) doesn't have VME, and guest (dosemu) is trying to enable it.

Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread Paolo Bonzini
On 07/12/20 12:24, stsp wrote: It tries to enable VME among other things. qemu appears to disable VME by default, unless you do "-cpu host". So we have a situation where the host (which is qemu) doesn't have VME, and guest (dosemu) is trying to enable it. Now obviously KVM_SET_CPUID doesn't

KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread stsp
[re-send because of bad formatting] 09.10.2020 18:30, Sean Christopherson пишет: The only other effect of setting VMXE was clearing VME. Which shouldn't affect anything either, right? Hmm, clearing VME would mean that exceptions/interrupts within the guest would trigger a switch out of v86 and

KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

2020-12-07 Thread stsp
09.10.2020 18:30, Sean Christopherson пишет: The only other effect of setting VMXE was clearing VME. Which shouldn't affect anything either, right? Hmm, clearing VME would mean that exceptions/interrupts within the guest would trigger a switch out of v86 and into vanilla protected mode. v86

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-11-13 Thread Paolo Bonzini
On 07/10/20 03:44, Sean Christopherson wrote: Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. The overarching issue is that kvm_x86_ops.set_cr4() can fail, but its invocation from __set_sregs(), a.k.a. KVM_SET_SREGS, ignores the result. Fix the issue by moving all

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-09 Thread Sean Christopherson
On Fri, Oct 09, 2020 at 06:48:21PM +0300, stsp wrote: > 09.10.2020 18:30, Sean Christopherson пишет: > >On Fri, Oct 09, 2020 at 05:11:51PM +0300, stsp wrote: > >>09.10.2020 07:04, Sean Christopherson пишет: > Hmm. But at least it was lying > similarly on AMD and Intel CPUs. :) > So I

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-09 Thread stsp
09.10.2020 18:30, Sean Christopherson пишет: On Fri, Oct 09, 2020 at 05:11:51PM +0300, stsp wrote: 09.10.2020 07:04, Sean Christopherson пишет: Hmm. But at least it was lying similarly on AMD and Intel CPUs. :) So I was able to reproduce the problems myself. Do you mean, any AMD tests are now

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-09 Thread Sean Christopherson
On Fri, Oct 09, 2020 at 05:11:51PM +0300, stsp wrote: > 09.10.2020 07:04, Sean Christopherson пишет: > >>Hmm. But at least it was lying > >>similarly on AMD and Intel CPUs. :) > >>So I was able to reproduce the problems > >>myself. > >>Do you mean, any AMD tests are now useless, and we need to

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-09 Thread stsp
09.10.2020 07:04, Sean Christopherson пишет: Hmm. But at least it was lying similarly on AMD and Intel CPUs. :) So I was able to reproduce the problems myself. Do you mean, any AMD tests are now useless, and we need to proceed with Intel tests only? For anything VMXE related, yes. What would

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-08 Thread Sean Christopherson
On Thu, Oct 08, 2020 at 09:18:18PM +0300, stsp wrote: > 08.10.2020 20:59, Sean Christopherson пишет: > >On Thu, Oct 08, 2020 at 07:00:13PM +0300, stsp wrote: > >>07.10.2020 04:44, Sean Christopherson пишет: > >>>Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. > >>Hi Sean

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-08 Thread stsp
08.10.2020 20:59, Sean Christopherson пишет: On Thu, Oct 08, 2020 at 07:00:13PM +0300, stsp wrote: 07.10.2020 04:44, Sean Christopherson пишет: Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. Hi Sean & KVM devs. I tested the patches, and wherever I set VMXE in CR4,

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-08 Thread Sean Christopherson
On Thu, Oct 08, 2020 at 07:00:13PM +0300, stsp wrote: > 07.10.2020 04:44, Sean Christopherson пишет: > >Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. > Hi Sean & KVM devs. > > I tested the patches, and wherever I > set VMXE in CR4, I now get > KVM: KVM_SET_SREGS:

Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-08 Thread stsp
07.10.2020 04:44, Sean Christopherson пишет: Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. Hi Sean & KVM devs. I tested the patches, and wherever I set VMXE in CR4, I now get KVM: KVM_SET_SREGS: Invalid argument Before the patch I was able (with many problems, but

[PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup

2020-10-06 Thread Sean Christopherson
Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. The overarching issue is that kvm_x86_ops.set_cr4() can fail, but its invocation from __set_sregs(), a.k.a. KVM_SET_SREGS, ignores the result. Fix the issue by moving all validity checks out of .set_cr4() in one way or