Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933052AbcLNPup (ORCPT ); Wed, 14 Dec 2016 10:50:45 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36739 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932405AbcLNPun (ORCPT ); Wed, 14 Dec 2016 10:50:43 -0500 Subject: Re: [PATCH v2 2/4] KVM: x86: replace kvm_apic_id with kvm_{x,x2}apic_id To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , David Hildenbrand References: <20161213163001.4567-1-rkrcmar@redhat.com> <20161213163001.4567-3-rkrcmar@redhat.com> <20161214134131.GA2156@potion> Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Igor Mammedov From: Paolo Bonzini Message-ID: Date: Wed, 14 Dec 2016 16:50:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161214134131.GA2156@potion> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2027 Lines: 57 On 14/12/2016 14:41, Radim Krčmář wrote: > 2016-12-14 13:39+0100, David Hildenbrand: >> Am 13.12.2016 um 17:29 schrieb Radim Krčmář: >>> There were three calls sites: >>> - recalculate_apic_map and kvm_apic_match_physical_addr, where it would >>> only complicate implementation of x2APIC hotplug; >>> - in apic_debug, where it was still somewhat preserved, but keeping the >>> old function just for apic_debug was not worth it >>> >>> Signed-off-by: Radim Krčmář >>> --- >>> arch/x86/kvm/lapic.c | 41 ++++++++++++++++++++++++++++++----------- >>> arch/x86/kvm/lapic.h | 11 ----------- >>> 2 files changed, 30 insertions(+), 22 deletions(-) >>> >>> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c >>> index 09edd32b8e42..e645b4bc6437 100644 >>> --- a/arch/x86/kvm/lapic.c >>> +++ b/arch/x86/kvm/lapic.c >>> @@ -115,6 +115,16 @@ static inline int apic_enabled(struct kvm_lapic *apic) >>> (LVT_MASK | APIC_MODE_MASK | APIC_INPUT_POLARITY | \ >>> APIC_LVT_REMOTE_IRR | APIC_LVT_LEVEL_TRIGGER) >>> >>> +static inline u8 kvm_xapic_id(struct kvm_lapic *apic) >>> +{ >>> + return kvm_lapic_get_reg(apic, APIC_ID) >> 24; >>> +} >>> + >>> +static inline u32 kvm_x2apic_id(struct kvm_lapic *apic) >>> +{ >>> + return apic->vcpu->vcpu_id; >>> +} >>> + >>> static inline bool kvm_apic_map_get_logical_dest(struct kvm_apic_map *map, >>> u32 dest_id, struct kvm_lapic ***cluster, u16 *mask) { >>> switch (map->mode) { >>> @@ -159,13 +169,13 @@ static void recalculate_apic_map(struct kvm *kvm) >>> struct kvm_apic_map *new, *old = NULL; >>> struct kvm_vcpu *vcpu; >>> int i; >>> - u32 max_id = 255; >>> + u32 max_id = 256; /* enough space for any xAPIC ID */ >> >> Why exactly do we have to increase this? >> >> I thought the maximum xapic id is 255, and we correctly allocate >> 255+1 slots. >> >> Now, we would allocate 257 slots and set max_apic_id to 256. > > Right, it is a typical off-by-one error. The comment is sufficient ... I can change it myself too. Paolo