From: Andrew Cooper Subject: [PATCH] x86/hvm: Further restrict access to x2apic MSRs Date: Thu, 16 Oct 2014 19:04:32 +0100 Message-ID: <1413482672-16865-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Kevin Tian , Keir Fraser , Jun Nakajima , Andrew Cooper , Eddie Dong , Donald Dugger , Jan Beulich , Matt Wilson , Yang Zhang , Feng Wu List-Id: xen-devel@lists.xenproject.org The x2apic specification reserves the entire MSR range 0x800-0xbff, while only the first 0x3f MSRs have defined purposes. Xen used to pass this entire range to hvm_x2apic_msr_{read,write}(), but the range was restricted somewhat by XSA-108 (c/s 61fdda7ac) to prevent guests being able to read pages adjacent to the domheap page backing the vlapic->regs array. While removing the vulnerability, a side effect of XSA-108 was that the MSR range 0x900-0xbff fell through the switch statement and ends up reading the hosts x2apic range. This behaviour is a problem in general, but specifically it turns out that MSRs 0xa00 and 0xa01 are implemented (but undocumented) on certain SandyBridge and IvyBridge systems. Experimentally, no operating system in XenServer's test suite (including all versions of Windows currently supported by Microsoft) ever peek at these MSRs, even on hosts where some of them are implemented. Therefore, direct the entire reserved range (0x840-0xbff) unconditionally at a side effect of this change is that hvm_x2apic_msr_read() can now no longer read beyond the bounds of the vlapic->regs array (which is 1/4 the size of the page backing it). Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich CC: Matt Wilson CC: Yang Zhang CC: Kevin Tian CC: Feng Wu CC: Eddie Dong CC: Donald Dugger CC: Jun Nakajima --- xen/arch/x86/hvm/hvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index f0e1edc..5680292 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4355,8 +4355,9 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) *msr_content = vcpu_vlapic(v)->hw.apic_base_msr; break; - case MSR_IA32_APICBASE_MSR ... MSR_IA32_APICBASE_MSR + 0xff: + case MSR_IA32_APICBASE_MSR ... MSR_IA32_APICBASE_MSR + 0x3f: if ( hvm_x2apic_msr_read(v, msr, msr_content) ) + case MSR_IA32_APICBASE_MSR + 0x40 ... MSR_IA32_APICBASE_MSR + 0x3ff: goto gp_fault; break; @@ -4482,8 +4483,9 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content) vlapic_tdt_msr_set(vcpu_vlapic(v), msr_content); break; - case MSR_IA32_APICBASE_MSR ... MSR_IA32_APICBASE_MSR + 0xff: + case MSR_IA32_APICBASE_MSR ... MSR_IA32_APICBASE_MSR + 0x3f: if ( hvm_x2apic_msr_write(v, msr, msr_content) ) + case MSR_IA32_APICBASE_MSR + 0x40 ... MSR_IA32_APICBASE_MSR + 0x3ff: goto gp_fault; break; -- 1.7.10.4