Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755637AbcDGIXI (ORCPT ); Thu, 7 Apr 2016 04:23:08 -0400 Received: from mail-by2on0089.outbound.protection.outlook.com ([207.46.100.89]:11860 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751412AbcDGIWP (ORCPT ); Thu, 7 Apr 2016 04:22:15 -0400 Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; From: Suravee Suthikulpanit To: , , , , , CC: , , , , Suravee Suthikulpanit Subject: [PART1 RFC v4 09/11] svm: Do not expose x2APIC when enable AVIC Date: Thu, 7 Apr 2016 03:20:30 -0500 Message-ID: <1460017232-17429-10-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: KL1PR02CA0009.apcprd02.prod.outlook.com (10.165.15.19) To SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) X-MS-Office365-Filtering-Correlation-Id: 5e7da832-0e91-4798-c0af-08d35ebdb53f X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0445;2:Pj5C+9j+QQjBHbU4P7DLR/hskZqvW7WT6CNOSDuuOXRG3oFVg2rmUy2wPd/UDegT8EkKdhPQq5Hdws2Pji1JT2PqQ5aM2WU/QQjYpx7EL8ZtSlQrRp5UqhU+NZESqZWYHoZklprTcFhkEQ5Di+lhy33nURAmj6f14B0WWyUfyyhVuoxwA07vbTrh1PaPjqe2;3:PYSacA9fktfn1gTvuvGS5/oIIzi2rs26LNh+6xG0NomN7UofqTZurAL+QLcwwMaq5w/6buXkOV6rpCLRCJa9xYGeEVKP+XEvHIaMdC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nnBhe7VW9wkeOG/wqYVNdekHByQ9YcIadUOrabC1zZ9NALPRqqOtY9Epw9g2cqfYHaVSjplu+3ljbxVR3p6XDY12loCzZ9A5HR8Wvk8ASqDj3e3swvxVo6OW30Qs1W66KKzklFCiUj73ZY3rpGYbyUwcXFHXYONcte0vJP8VjOTFEw3X5pb20RV3BQNCaTUSOD1xYrnVrpdGL80z2cMRyd/acwHRJiYIvm61kvMtV4XiFLv71lNjlVZXT+AbZY53M1495VrET/iRZVIn5GPACM886orvrdwSLYwSSU3Xb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:SN1PR12MB0445;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0445; X-Forefront-PRVS: 0905A6B2C7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(5001770100001)(50466002)(2906002)(48376002)(50986999)(189998001)(77096005)(4326007)(2950100001)(36756003)(5003940100001)(92566002)(76176999)(47776003)(19580395003)(19580405001)(81166005)(2201001)(229853001)(50226001)(86362001)(42186005)(586003)(3846002)(5008740100001)(66066001)(1096002)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0445;H:localhost.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0445;23:OLxjHaJNF1EGQ21nJWMCh/LHPPcewyZQUWMs/lufHwmvPuYrOB/REtu/M7ab8dMPPW/8EOndVhj68nq90ePy5npgqbDMR0qGiH+3drdctq7m2dwRmgenKcwqFPUWZ0eQRFFAWMaKGN66CWT4grL/XwkNNrWU4zFt0mj6g1pjI6+Ybb+nZFB+0nERRTZ8+gbWM6VKuIqnRrQLa7C3R7sSaXAjmwerfWlAbCUBQvs2M65WavLR/VlhgaIp9Ixu02i+cq5jTgg5gsLqjzj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ul/Z9w0iJfTU7f/yp4imCmTOsutD2ZkkzyY8Zkvnncenj3GHpWkvRbzUG0R3daIUFDnwRyHg1qdHhbk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2016 08:22:03.7835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0445 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1222 Lines: 43 From: Suravee Suthikulpanit Since AVIC only virtualizes xAPIC hardware for the guest, this patch disable x2APIC support in guest CPUID. Signed-off-by: Suravee Suthikulpanit --- arch/x86/kvm/svm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 13fba3b..74b0751 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4560,14 +4560,26 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) static void svm_cpuid_update(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); + struct kvm_cpuid_entry2 *entry; /* Update nrips enabled cache */ svm->nrips_enabled = !!guest_cpuid_has_nrips(&svm->vcpu); + + if (!svm_vcpu_avic_enabled(svm)) + return; + + entry = kvm_find_cpuid_entry(vcpu, 0x1, 0); + if (entry->function == 1) + entry->ecx &= ~bit(X86_FEATURE_X2APIC); } static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) { switch (func) { + case 0x00000001: + if (avic) + entry->ecx &= ~bit(X86_FEATURE_X2APIC); + break; case 0x80000001: if (nested) entry->ecx |= (1 << 2); /* Set SVM bit */ -- 1.9.1