From patchwork Tue Jan 28 12:52:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11354207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6C3314B7 for ; Tue, 28 Jan 2020 12:53:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8FFE824681 for ; Tue, 28 Jan 2020 12:53:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="VgDrQyBz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FFE824681 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iwQLt-0001bx-WB; Tue, 28 Jan 2020 12:52:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iwQLs-0001bs-Te for xen-devel@lists.xenproject.org; Tue, 28 Jan 2020 12:52:20 +0000 X-Inumbo-ID: 04e710c2-41cd-11ea-86b5-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 04e710c2-41cd-11ea-86b5-12813bfff9fa; Tue, 28 Jan 2020 12:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580215940; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9e8MGA3QPhlOD4wDtQCnT7xfuSmvzNE6tgP6jdHgSrE=; b=VgDrQyBzHc6SI52wAoHKF4hCuJdARsjjvxqHvIyIBFpC8zUyJrFizFSY C8UmPyltu8tmC7HRtZHeh8Bdx2xuOAVfnKeOWZbwCY9vBdhBH42O7pUTP tP+SQYzqiK3O+pGpsOzA0RwJqEsj0rnV93W5wCOiMVUKv2cM7ucnBM7mP s=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: U1B0b7/uW4NF+labMYCDXNo52JaU+gSIXivxMpUsqYUEOVHhFP1NGFsaJD4CutNcK9PiJGgoOh t+4iG5oeMbXu7v18QxPQjkQNubLbMpHGNaZ5Usz5oVMo7t2RcJBAa4P+DV/AIKiuFxUkIDDqDE SBDNfpvjJN78vr11N0NpG+dHp5FApkd2TvIX4KSOmkIhiIQdEbhRtBXIZNcwUJ4Z6bTME2H705 VMv+9/pcY3E83m4hakKr4ob+rc5NwXwFaNkCTYm1+xIARTJAff3Gm1EjFIBMGF0xFrLWa/IVXl 23w= X-SBRS: 2.7 X-MesageID: 11722675 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,373,1574139600"; d="scan'208";a="11722675" From: Andrew Cooper To: Xen-devel Date: Tue, 28 Jan 2020 12:52:16 +0000 Message-ID: <20200128125216.709-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/apic: Improve current_local_apic_mode() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" boot_cpu_has(X86_FEATURE_X2APIC) doesn't need checking to interpret APIC_BASE_EXTD. Also take the opportunity to optimise the generated assembly by not using rdmsrl(). GCC isn't clever enough to spot that it can drop the shift and or to put %eax in the higher half of msr_contents. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné What can I say - the numpty who wrote that code was young and naive... --- xen/arch/x86/apic.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index a6a7754d77..0684c5d9c2 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -1534,18 +1534,14 @@ void __init record_boot_APIC_mode(void) /* Look at the bits in MSR_APIC_BASE and work out which APIC mode we are in */ enum apic_mode current_local_apic_mode(void) { - u64 msr_contents; + uint32_t high, low; - rdmsrl(MSR_APIC_BASE, msr_contents); + rdmsr(MSR_APIC_BASE, low, high); - /* Reading EXTD bit from the MSR is only valid if CPUID - * says so, else reserved */ - if ( boot_cpu_has(X86_FEATURE_X2APIC) && (msr_contents & APIC_BASE_EXTD) ) + if ( low & APIC_BASE_EXTD ) return APIC_MODE_X2APIC; - /* EN bit should always be valid as long as we can read the MSR - */ - if ( msr_contents & APIC_BASE_ENABLE ) + if ( low & APIC_BASE_ENABLE ) return APIC_MODE_XAPIC; return APIC_MODE_DISABLED;