From patchwork Fri May 3 13:37:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 10928779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E4F714C0 for ; Fri, 3 May 2019 13:37:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E2CC2838F for ; Fri, 3 May 2019 13:37:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81EAA285D9; Fri, 3 May 2019 13:37:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E43232838F for ; Fri, 3 May 2019 13:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbfECNhb (ORCPT ); Fri, 3 May 2019 09:37:31 -0400 Received: from mail-eopbgr760074.outbound.protection.outlook.com ([40.107.76.74]:33601 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726377AbfECNhb (ORCPT ); Fri, 3 May 2019 09:37:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5c8hWceaDcibDPAXCrTKB0OMZEq7b6N268RW0RHpjFY=; b=hEkSDOdpCT8XvAeY/iGDEyAooUhdCVp9I+KLjN9GvFXyzAc49Ig3FlBHRgRgc+/wNkPx2dmN41XTbPAat+ZrE9OnPZgmL4YD0JtIb/v4JueYOeMUMAKmma9GHHJRaYBRV04jFxnUzVBcgZIursTcvBiPSFsxDSRkRLM9vUY4qoo= Received: from DM6PR12MB2844.namprd12.prod.outlook.com (20.176.117.96) by DM6PR12MB3212.namprd12.prod.outlook.com (20.179.105.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.10; Fri, 3 May 2019 13:37:27 +0000 Received: from DM6PR12MB2844.namprd12.prod.outlook.com ([fe80::d119:23e5:be33:4ac6]) by DM6PR12MB2844.namprd12.prod.outlook.com ([fe80::d119:23e5:be33:4ac6%2]) with mapi id 15.20.1856.008; Fri, 3 May 2019 13:37:27 +0000 From: "Suthikulpanit, Suravee" To: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" CC: "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "joro@8bytes.org" , "Suthikulpanit, Suravee" Subject: [PATCH] svm/avic: Allow avic_vcpu_load logic to support host APIC ID 255 Thread-Topic: [PATCH] svm/avic: Allow avic_vcpu_load logic to support host APIC ID 255 Thread-Index: AQHVAbVYshI13bVJeUaA1Du2DOEuSw== Date: Fri, 3 May 2019 13:37:27 +0000 Message-ID: <1556890631-9561-1-git-send-email-suravee.suthikulpanit@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [165.204.78.1] x-clientproxiedby: SN2PR01CA0038.prod.exchangelabs.com (2603:10b6:804:2::48) To DM6PR12MB2844.namprd12.prod.outlook.com (2603:10b6:5:45::32) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.8.3.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 83a348eb-59db-4362-798a-08d6cfcc7b3c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:DM6PR12MB3212; x-ms-traffictypediagnostic: DM6PR12MB3212: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0026334A56 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(136003)(376002)(346002)(396003)(189003)(199004)(8936002)(386003)(4720700003)(3846002)(6116002)(66066001)(6512007)(14454004)(25786009)(66556008)(68736007)(71200400001)(71190400001)(64756008)(6506007)(316002)(52116002)(66476007)(2501003)(36756003)(8676002)(50226002)(4744005)(7736002)(54906003)(81156014)(81166006)(99286004)(305945005)(66946007)(73956011)(256004)(66446008)(4326008)(486006)(5660300002)(478600001)(186003)(110136005)(2906002)(72206003)(6436002)(26005)(53936002)(476003)(6486002)(2616005)(102836004)(86362001)(14444005);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3212;H:DM6PR12MB2844.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jvW7uBW8VvlcRXMqdV2oKiPIq3wBSOcEFm0jYeZO0UVyBJEVMHdmv79/nqLbDY36SJ2CDAhoFpZ1/Xf3ZqG3F2Ry/2+7ZU1fIercHkEQaMI+pjPeYRktsOoiDsXCP0nwhg64/sNrwdySzc5I+jyh17rMWcOTyrGegcPARaVzvUdv41nfh4KiNpzEMnoIfDd1mXptTuLE0LLIa+v2cmpWlm4fjo0gHhNAUb6jL2AvFEbjrCAO7Ge7O6PvsQI8uk+/FZi9TgcO7MBiuoAptTTW+LY36WZYipaxQnHFmUDW3VRQ3Ick9+rQsTAbs1eZlvjXSD28LAk94EOOtqDzJIzGV/kJNLccsoL3a//xTTzwaDugDA1asfrBRLIARKtXBUt/qNryFIavGc67zwYYREGt69WfjZjkA1G7yXmjivb7IxM= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83a348eb-59db-4362-798a-08d6cfcc7b3c X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2019 13:37:27.1445 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3212 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current logic does not allow VCPU to be loaded onto CPU with APIC ID 255. This should be allowed since the host physical APIC ID field in the AVIC Physical APIC table entry is an 8-bit value, and APIC ID 255 is valid in system with x2APIC enabled. Instead, do not allow VCPU load if the host APIC ID cannot be represented by an 8-bit value. Signed-off-by: Suravee Suthikulpanit --- arch/x86/kvm/svm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 294448e..122788f 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2071,7 +2071,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu) if (!kvm_vcpu_apicv_active(vcpu)) return; - if (WARN_ON(h_physical_id >= AVIC_MAX_PHYSICAL_ID_COUNT)) + /* + * Since the host physical APIC id is 8 bits, + * we can support host APIC ID upto 255. + */ + if (WARN_ON(h_physical_id > AVIC_MAX_PHYSICAL_ID_COUNT)) return; entry = READ_ONCE(*(svm->avic_physical_id_cache));