Skip to contentSkip to conversation

EFER in HVM guests

DISCUSSION Jan Beulich 3 participants 6 messages Nov 29, 2006

lore
Share & tools
lore
#0 lore raw

Is it intentional that
- under SVM, 32-bit guests can freely set EFER.LME
- under VMX, 32-bit guests can't access EFER at all?

Thanks, Jan

#1 lore raw
Quoted 5 lines · Jan Beulich

Is it intentional that
- under SVM, 32-bit guests can freely set EFER.LME
- under VMX, 32-bit guests can't access EFER at all?

Thanks, Jan

I'm sure any differences are unintentional. There is obviously scope for making much of the MSR and CPUID code non-vmx/svm specific.

I assume that this particular difference doesn't really matter?

-- Keir

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 29.11.06 14:09 >>>

Quoted 4 lines · Jan Beulich

Is it intentional that
- under SVM, 32-bit guests can freely set EFER.LME
- under VMX, 32-bit guests can't access EFER at all?

Quoted 6 lines
Quoted 1 line

Thanks, Jan

I'm sure any differences are unintentional. There is obviously scope for making much of the MSR and CPUID code non-vmx/svm specific.

I assume that this particular difference doesn't really matter?

I think it does - allowing a guest to enable EFER.LME when the hypervisor is a 32-bit one is clearly a security problem: While I haven't tried it, I would suspect the moment you load a context with such an EFER the whole system's dead.
Not being able to access EFER is also a potential problem, as a guest should be allowed to set EFER.NX (at least) - the CPUID handling code specifically does not suppress this bit if the guest is allowed to use PAE (which we agreed a few days ago should be the default anyway).

Jan

#3 lore raw
Quoted 21 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 29 November 2006 14:08
To: [email protected]; Keir Fraser
Subject: Re: [Xen-devel] EFER in HVM guests

Quoted 10 lines
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 29.11.06 14:09 >>>

Quoted 5 lines · Jan Beulich

Is it intentional that
- under SVM, 32-bit guests can freely set EFER.LME
- under VMX, 32-bit guests can't access EFER at all?

Thanks, Jan

I'm sure any differences are unintentional. There is

obviously scope for

Quoted 8 lines
Quoted 3 lines

making much of the MSR and CPUID code non-vmx/svm specific.

I assume that this particular difference doesn't really matter?

I think it does - allowing a guest to enable EFER.LME when the hypervisor is a 32-bit one is clearly a security problem: While I haven't tried it, I would suspect the moment you load a context with such an EFER the whole system's dead.

Actually, it's a bit more complex than that, but assuming the guest has access to EFER, it also has access to CR0, so it could try to enable long mode by:
CR0.PG = 0
CR4.PAE = 1
EFER.LME = 1
CR0.PG = 1

If PAE isn't available, it wouldn't be possible to set long-mode (processor consistency checks for PAE=1 when LME=1). See section 14.6.3 in the AMD Programmers Manual Vol 2.

I think that the setting of EFER.LME in 32-bit Hypervisor should generate GP-fault, as that's what the real processor does...

Quoted 5 lines

Not being able to access EFER is also a potential problem, as a guest should be allowed to set EFER.NX (at least) - the CPUID handling code specifically does not suppress this bit if the guest is allowed to use PAE (which we agreed a few days ago should be the default anyway).

This makes sense to me. As well as EFER.SCE, perhaps?

--
Mats

Quoted 10 lines

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
In reply to Jan Beulich
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 29 November 2006 13:07
To: [email protected]
Subject: [Xen-devel] EFER in HVM guests

Quoted 2 lines

Is it intentional that
- under SVM, 32-bit guests can freely set EFER.LME

Ehm, I guess you mean "on 32-bit hypervisor", as it's impossible to distinguish a 32-bit and 64-bit guest until the guest is setting LME... ;-).

The correct reaction for a 32-bit hypervisor is to react like a "non-64-bit capable processor", which means that EFER has the LME as a mbz-bit. GP-fault if it's written as a one. We do prevent the long-mode from being advertised by CPUID when HV is in 32-bit mode, so if the guest is well-behaved, it shouldn't try to set this bit.

--
Mats

Quoted 11 lines

- under VMX, 32-bit guests can't access EFER at all?

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
Quoted 6 lines
Quoted 2 lines

Is it intentional that
- under SVM, 32-bit guests can freely set EFER.LME

Ehm, I guess you mean "on 32-bit hypervisor", as it's impossible to distinguish a 32-bit and 64-bit guest until the guest is setting LME... ;-).

Yes, sorry for being imprecise. I meant a 32-bit hvm guest on a 32-bit hv.

Jan