Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754118AbdIFDkO (ORCPT ); Tue, 5 Sep 2017 23:40:14 -0400 Received: from mail-dm3nam03on0081.outbound.protection.outlook.com ([104.47.41.81]:45280 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753347AbdIFDkI (ORCPT ); Tue, 5 Sep 2017 23:40:08 -0400 From: Suravee Suthikulpanit To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, joro@8bytes.org, Suravee Suthikulpanit Subject: [PATCH 1/3] KVM: SVM: Refactor AVIC vcpu initialization into avic_init_vcpu() Date: Tue, 5 Sep 2017 22:39:27 -0500 Message-Id: <1504669169-4919-2-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504669169-4919-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1504669169-4919-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: SG2PR06CA0102.apcprd06.prod.outlook.com (10.170.138.28) To DM5PR12MB1737.namprd12.prod.outlook.com (10.175.89.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f543a8b-91a8-4bae-625f-08d4f4d8f751 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM5PR12MB1737; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;3:lthnCRT28EPiGfbmFj+O09E7VgWTU36tKksCTCg8U5ady7CRacG5f541gAWxHQZKvPEGBbnJtfGs39/WaMVFt8da/mCRPfNdqkt8PnqmZEi26p0B1tc4Pvo7MJ41J+ghiGr8XZUIB57cvnaTtpu4b13ECrjWwAfRMoWNp0ItqDUOr5v77Pa9veOS21wXANLFkBe/FlFWiYMirLn+Tul9BmFBEom2t0o6V5A6iEyGfw7o9b+auonlC5NrOe90nK70;25:C8LXnYD2yvfUCrLk5pfOqWp6egJzXc9rVwyoTIltTkFkd47HmMIu2QMC4I/taEzAELiU1hOhzgh5IOYLcG9sKq5n2MnezQHANPmevOhsINLDcgJBYAqcZfjc/F2ZlMaKZif0QwHVLL3MDq0qfaR6zscAp0VA0K8khuUhkOST2AgI37c/DdkywbfCrJQEi+vNmU/yg4p4buh8yIDdHyf6YgU353bceSpZuTHlvl2/35g5JEpQLkPxrz0R2ePsAHTPXYX+WeoACYlLuLkZxIq4lQboYXIkrgz6hK+ss9i43ohOf3Id31+8HurmSz7S8mgOcQxZXILsVkqMzWRrpddb3w==;31:7DBuwjmuoLopZIHhYz8gEQzOiePHLL+kZT3XCoytbkUsoVejlNBFMZotB0c8As2VEyrlmWBYHZKhTPUa3Ws7VAsCLRo9/EbzHne++M4AtpHxH0I6a1SJgH1jUcNuzCqvNV0aVHMltveWVQgxW1o1Z01qW2u+Ik7olTBJ00FCMUSxw0Ql3qitlQkSb6eUpNAsqNcGp5uN8lJF28MPm6CqdkBlz/vR2iwMSw94ixacsKM= X-MS-TrafficTypeDiagnostic: DM5PR12MB1737: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;20:JXnpwtp1e3mCri2HEZblFRDxmDyjUtMt8FdOf1Z0zqE905u9fJ7tPh5WImMXNl8Gg6Ex5qKt5ynwhllLz8PI+YZNMWM0JCp+xwgAoMFTePur0hhPaaMgOoVebuG0QSnNu6dhUVYKrQ89mcQNFbgswhkuOi7Olvht4twOfjxUdXvmCafDydQFRdZ0ulJ47uG0jPiXhpmikw3z3xSWqQ0VHkdgXneILkCvY/NST8gwxwcj41JtoxOEWvhcwYkP0pc/CPAH+8zUciR5Vs297WOObdG5odDZYoLb5h11ikebvm0799S+YGOA8juxmzaEYgwG3EQasKB5i2G10MFXrMj3IhI9FpL4PQmHkR7y1xWH5XsvcrIqq8twEuUgneGq5yomW9gyrcYPA2heo/GG9+FGVNoBgM2NTFiblaRfQwAxOYhEOi/CB1SrUE95ZerReEz+fI3Zndfkp0mj9HNVW7BNSH6KtbzMBSJCdjU0zh95uasA6jyMVOu5BcN9mr6MjUKV;4:v0yGS/fN1LqzmbKU55IQiG1WXpqC/wsVHguJjwS/hc9psRaNaJjkzalqc/ypKdZhP86L7szAHuoLECoAVjCSYvECcdkTM0l6rYjGGgLynIEgC3QPUWIac7JfgGH+T9KGdgQokfMVS5LqREQHL6R+AME1nU44t8AwjdYQWfpGqQTqrSqMpcX9vh+OxccRu+dM9N9czL+PdlgLhCeJyWegwwdH8RmBjRUsSrCZqYPQiSpPW9gQ/ia56Vxn/hGCTelQ0j+2ySamDq8BrPQX+wOxisC3fyhNE49ICmBBPVcYFPw= 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR12MB1737;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR12MB1737; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(199003)(189002)(8936002)(6666003)(2950100002)(6116002)(86362001)(53936002)(4720700003)(101416001)(6486002)(42186005)(106356001)(5660300001)(5003940100001)(105586002)(3846002)(110136004)(305945005)(4326008)(6506006)(72206003)(7736002)(76176999)(66066001)(47776003)(478600001)(25786009)(2906002)(8676002)(97736004)(50986999)(68736007)(50226002)(36756003)(81166006)(33646002)(81156014)(50466002)(189998001)(48376002)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1737;H:ssuthiku-rhel73-zp.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR12MB1737;23:LmFBd+Q0cXWMR2E9WwP4S8QecLVqb/0anVZTzwKYJ?= =?us-ascii?Q?ZZ7cRYHHJ1fiNRGsKjdSAmzyQbetjQDJ1OsOGFLpKLr+jbdoz1+UAeFaF3qB?= =?us-ascii?Q?ASxDIYbMAvZdDXsKBrhvky+pRr+g72uQSjqLXYqKV0icfCUearsnEMLhZqCr?= =?us-ascii?Q?aR0IoqUBl8/LtnOJ+6yisE3gexbx5vWTuYZQ1DDPZY+VF7ymk+8w19Ypzkv2?= =?us-ascii?Q?4zmSTjeE3it/6VgurAoeVrGOyvCZpQWqO5Dj+wNWw3GVln4fXQrirzgBaUTe?= =?us-ascii?Q?IzzZxC0aHcFkHktTqd2x9H2p+TErD6kXUnbolr7yT4cbj2os274FciPB8knN?= =?us-ascii?Q?IiKLXoC6WIFPP8iYMY+jjGoE+mZ32W3jXBm6T7E1itIEHKsGblTL7QohiCHn?= =?us-ascii?Q?v57h5tQChrqy/dVNprbFg2jdNTRIW7uRj8ikEhajGR1ihuMRw9ISdIdnliPE?= =?us-ascii?Q?h075WxCPtzRFCwamGdu3fAi26vymO7f7dr5EuPFTqpzA63JNz+aCcWqlrwTj?= =?us-ascii?Q?ZeGDlCRaHWkFM/j5Mx9d++z28Js/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ZqIv+lr0g7Q06axcCCpFJYFv21zKVdod4pbNhhez5odmpWGWWkeFFW2lcdmi0nEh7y4XOl5IpkiQjoJdjR/Xpmvat3kqSzxcVYFxL751/P8h+YKLGKQ==;24:5iTz5otloyd3+xve4J746Cl6PKW6WFNqFfBWelRcGiHcv+HLcYs7jH7HwnRVAWl6Yso/pXqHa/uSoQjV0xTSdcGMs7ykxCq5BYpLGxRQY34=;7:Snt/GI5WUeCPUUQCPmMOPr1X4xjRVelW4tEOchooHKyPZVbIlC85ByOzFOjHtGgGdKYak9wJuX/dBnjUWVEYNR/Dra5AGh8oNC4SJcS5e2htJfbLMvyyuSzIwRpGYp1weo/HXlLRcF32msewKzawEKUH6Fho0YSbdzL02v+cxvQkQDeQ7B8tmvJI1DBJx9tlEHrtbQeBR0Ty4IyZi/ImT0vJlt80VkBokjYghzFyM+M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1737;20:1eiPHDBOUcbBonpvgPnvGn1RQzrHObzaNTpK3h+Slm4uaNbeudfRg5NytxJdXn1OgKlpLmlAr9obWxlPqfBSF41u3hSXXZbL2kwUUgqBo1WsEmRagTOSTtEzAPeR7CftMVOPiYW9ZJLUIbr1msqBPuPDhznA/Qm0mRwJKve8KkwNJHR9yt4sO2CsjDyMGkYYQu3TdsIJYsEoRcAcn673Ki5/spihH2nGPU0Qg4OWgCHQMCiT5OHEZ0QAIPINMYnu X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 03:40:04.4251 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1737 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