From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/3 v2] x2APIC interface to local apic Date: Mon, 29 Jun 2009 12:42:02 +0300 Message-ID: <4A488C6A.2040703@redhat.com> References: <1246191331-31085-1-git-send-email-gleb@redhat.com> <1246191331-31085-3-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx2.redhat.com ([66.187.237.31]:60893 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbZF2Jk2 (ORCPT ); Mon, 29 Jun 2009 05:40:28 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5T9eVk7022551 for ; Mon, 29 Jun 2009 05:40:31 -0400 In-Reply-To: <1246191331-31085-3-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/28/2009 03:15 PM, Gleb Natapov wrote: > This patch implements MSR interface to a local apic as defines by x2APIC > Intel specification. > > @@ -269,7 +275,12 @@ int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest) > int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda) > { > int result = 0; > - u8 logical_id; > + u32 logical_id; > + > + if (apic_x2apic_mode(apic)) { > + logical_id = apic_get_reg(apic, APIC_LDR); > + return logical_id& (uint16_t)mda; > + } > mda is u8, why cast it? > +static int apic_reg_read(struct kvm_lapic *apic, u32 offset, int len, > + void *data) > { > - struct kvm_lapic *apic = to_lapic(this); > - unsigned int offset = address - apic->base_address; > unsigned char alignment = offset& 0xf; > u32 result; > + /* this bitmask has a bit cleared for each reserver register */ > + static const uint64_t rmask = 0x43ff01ffffffe70c; > s/uint64_t/u64/, add ULL to avoid warnings on i386? > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 5a66bb9..8ead54d 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -817,6 +817,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) > case MSR_IA32_APICBASE: > kvm_set_apic_base(vcpu, data); > break; > + case APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff: > + return kvm_x2apic_msr_write(vcpu, msr, data); > Might be a good idea to special cases these in arch code to avoid the long if-trees the switches generate. Only after profiling though. -- error compiling committee.c: too many arguments to function