Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbdILPn6 (ORCPT ); Tue, 12 Sep 2017 11:43:58 -0400 Received: from mail-bl2nam02on0080.outbound.protection.outlook.com ([104.47.38.80]:8448 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751686AbdILPnC (ORCPT ); Tue, 12 Sep 2017 11:43:02 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; From: Suravee Suthikulpanit To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, joro@8bytes.org, Suravee Suthikulpanit Subject: [PATCH v2 1/3] KVM: SVM: Refactor AVIC vcpu initialization into avic_init_vcpu() Date: Tue, 12 Sep 2017 10:42:40 -0500 Message-Id: <1505230962-86304-2-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505230962-86304-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1505230962-86304-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: BN6PR2001CA0014.namprd20.prod.outlook.com (10.172.112.152) To CY4PR12MB1733.namprd12.prod.outlook.com (10.175.62.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb504b65-a6a4-47a6-e9c9-08d4f9f4f218 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR12MB1733; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1733;3:HK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5HFAnsZfaZc6VeDt9huM9tdLpnmQR/4n2kKn7KK5wDI0z7DnLzYzpeOU5QYwrJD1fZoZouDYFnDyWHNv+4Ri3ObVFpKSwH9ErpDUZ+OIHcJ4NYApJt1QjBIC0qjjuput/cE/zAZ7gsKJWWFNJTayK0xrAxGvKLdyv0/pfYCsomOLKIRADfoQJxkrhTruj6atODBzPMLsdN2fCk/NzLb9YyjarnX3CHKlGrX5/tVS5fV/DuOtRoOp9BJBkx2TECGgMVuNBiOUoWyzTazOo0vz2nJB2PNxJcWFxuKNFgaE5eyCWITJVkzJaVnL2vL2DljjsA+pKcLmQt0gvrkXAoES;4:gn2KY3y16DMHejDNyGwDKDEJt7SumLO12xNvHEuGRHBQXBq4Y34HVfv8xo+CoHR1HoN6y+4HtkTeUJRQ9Ehk24uKuimFEhBl1pUKLO/wTt7+cMwSdaZpKWtQrbwMlpSI7bbC/lPSdorOgbYLEISNvitiNEjdHuklepGXIiIBGEsh6KA8EOjGal7/EKQsczKshJNDuIe1p/eLmQwYzhueHi84HL+mVkz4lWMV4YgzbXjODXauHJa1H/98G7rOEsbbhYwGWqK7B3Ie5F9mbJLh6vS0MqeC613/cfqO2+5s8Mg= X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123560025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR12MB1733;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR12MB1733; X-Forefront-PRVS: 042857DBB5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(199003)(189002)(305945005)(5660300001)(53416004)(7736002)(72206003)(2950100002)(25786009)(76176999)(2906002)(50986999)(106356001)(189998001)(4326008)(316002)(478600001)(33646002)(105586002)(101416001)(6486002)(48376002)(81166006)(36756003)(8936002)(47776003)(68736007)(3846002)(6116002)(81156014)(110136004)(42186005)(6666003)(97736004)(53936002)(50226002)(5003940100001)(8676002)(4720700003)(86362001)(66066001)(50466002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1733;H:dave-rhel73-ethanol.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR12MB1733;23:jxhmX5gDnd4VNh54zdeYgRtuVUnHl4xk9NpBd6b4V?= =?us-ascii?Q?gifetVy+fsqOZ4m/O+gGrxtd4g73uMiiSTraeL016qIO9o/WChOBzvtDdMYo?= =?us-ascii?Q?1ib1cGFyakvofN229wVy8smCcs/w1gW3RRx0YgIIMyjDALJDSNFoFzv/U9xi?= =?us-ascii?Q?sj1gpEqGeBIxfOGg9nlTskXosAMez9VfcuxeNEUK1vLHye5y2NPMpXYpEFSR?= =?us-ascii?Q?eUYDW1bP8MeUE7bSIir+9oYEqAVq6cJUmLzEAnzPwu04xxnGZuNPlJpfMzSH?= =?us-ascii?Q?Pfs12qStcRYDQ00JNT6hYsbeogqJa4K6phvTOmJeB4gl1C1YKWmu10QV1lK5?= =?us-ascii?Q?p2M0bmEZD0CloQG3W3gbjuiX9OSozShQCZ/mDrC23zvtfeEA3SIIAejJzOpQ?= =?us-ascii?Q?3meMG4L+rqdtVp5zyGlqKUNvI1Awq1W/uxu9Orao1KzrtBvq7yEQfnHTaWvs?= =?us-ascii?Q?fl9W85JcQZ9j9qTiLEsvSUtECd0upxvtxigE7iM1AEfH9bPdyQ2MdjGul5M4?= =?us-ascii?Q?FQxw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oXvZgRh9CcsiNjPust2ycKYUr8+NZyPBV791wtg1eDGeMhUenUkTsm/9wwwttjsiGk7h7/HukoDiVcA3rrMUtFv6fl7YqGduf/0OQvkGeX0o3z7dvoXbzN02s+hfy3PaSrxfW9Q==;24:j69jhxRVA02c9K83Mu/ICb/EzCMan6dLTAhcazrWSeuQOEYoQKskjk3Uivi16xaMtLnb6pI/HNj6Z1bbv897QPqvcfX0v4X5pn+EW/fh93U=;7:k4YgWMltJ+ZCMmMmiEUQAWYL1rkD8BqXBKsJnYBhcvFT5WIRrySaFzo5oeOeADWqEx3cKJKie1gt7EtknObNY6Rq8F38L0UCZTqI2IytnENJeMGkhmlkbak8ZK2UpC7v6+v2KrNRGV1a3J/IWZYbsV9ESosqHSq1KDd2bgOlfKp6mrwB0ObhBY5Sn3pn0PK1cqizeKebYKe8vKTdSaR6RP5sssZUrUyCNoYRHr7dJZg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1733;20:OZasurSi6wFqo5vbPOZz7NSGSTL07yhir6jkV9gfYFqMRMm3i2aJRkqzUWKBPMMyApzTPjmTY4czGG0q4Esrj3j2+tpBH+P/ai2fxan/b2nDvV6sGmNzyMueCKa+QywSsb2TpaA2hTLmoL26gRbvrsOYWalJrFeQ4vjrGNFQrGOZEe3qHT4u/KNF4LlvSnYOOMhPDnUSNG6vsNvzFpIyon/jqp0LtElx2EQodV6RqjdnMCPt3WTlvn2XWNld3Eak X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2017 15:42:58.5919 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1733 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1416 Lines: 56 Preparing the base code for subsequent changes. This does not change existing logic. Signed-off-by: Suravee Suthikulpanit --- arch/x86/kvm/svm.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index af256b7..316edbf 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1587,6 +1587,23 @@ static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) avic_update_vapic_bar(svm, APIC_DEFAULT_PHYS_BASE); } +static int avic_init_vcpu(struct vcpu_svm *svm) +{ + int ret; + + if (!avic) + return 0; + + ret = avic_init_backing_page(&svm->vcpu); + if (ret) + return ret; + + INIT_LIST_HEAD(&svm->ir_list); + spin_lock_init(&svm->ir_list_lock); + + return ret; +} + static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id) { struct vcpu_svm *svm; @@ -1623,14 +1640,9 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id) if (!hsave_page) goto free_page3; - if (avic) { - err = avic_init_backing_page(&svm->vcpu); - if (err) - goto free_page4; - - INIT_LIST_HEAD(&svm->ir_list); - spin_lock_init(&svm->ir_list_lock); - } + err = avic_init_vcpu(svm); + if (err) + goto free_page4; /* We initialize this flag to true to make sure that the is_running * bit would be set the first time the vcpu is loaded. -- 1.8.3.1