From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 04/12] KVM: x86: Validate guest writes to MSR_IA32_APICBASE Date: Thu, 16 Jan 2014 15:19:44 +0100 Message-ID: <52D7EA80.1080202@siemens.com> References: <158b5c8094a923e76ba3aff41052408efa8429df.1388857646.git.jan.kiszka@web.de> <52D7E793.5080005@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , Marcelo Tosatti , kvm To: Paolo Bonzini Return-path: Received: from david.siemens.de ([192.35.17.14]:16544 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752376AbaAPOTz (ORCPT ); Thu, 16 Jan 2014 09:19:55 -0500 In-Reply-To: <52D7E793.5080005@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2014-01-16 15:07, Paolo Bonzini wrote: > Il 04/01/2014 18:47, Jan Kiszka ha scritto: >> + u64 old_state = vcpu->arch.apic_base & >> + (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE); >> + u64 new_state = msr_info->data & >> + (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE); >> + u64 reserved_bits = ((~0ULL) << boot_cpu_data.x86_phys_bits) | 0x2ff | >> + (guest_cpuid_has_x2apic(vcpu) ? 0 : X2APIC_ENABLE); >> + > > Should this use the guest CPUID instead? Hmm, they may differ... Then yes. > >> + if (!msr_info->host_initiated && > > Is this check on host_initiated just for backwards compatibility, or is > there another case that I am missing? The path is taken for both host-initiated and guest-initiated APICBASE updates. Host-initiated ones are allowed to perform architecturally invalid state transitions. And the MSR is emulated, so if they like to set a reserved bit... Jan -- Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux