From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304AbdH1Of4 (ORCPT ); Mon, 28 Aug 2017 10:35:56 -0400 Received: from mail-by2nam03on0115.outbound.protection.outlook.com ([104.47.42.115]:56555 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751170AbdH1Ofy (ORCPT ); Mon, 28 Aug 2017 10:35:54 -0400 From: KY Srinivasan To: Thomas Gleixner , LKML CC: Ingo Molnar , Peter Anvin , "Peter Zijlstra" , Andy Lutomirski , "Borislav Petkov" , Steven Rostedt , Juergen Gross , Stephen Hemminger , "Boris Ostrovsky" Subject: RE: [patch V3 43/44] x86/idt: Simplify alloc_intr_gate Thread-Topic: [patch V3 43/44] x86/idt: Simplify alloc_intr_gate Thread-Index: AQHTH8p+JIQq8LNDlUOSJO0H4pQ86KKZ1YhQ Date: Mon, 28 Aug 2017 14:35:52 +0000 Message-ID: References: <20170828064715.802987421@linutronix.de> <20170828064959.580830286@linutronix.de> In-Reply-To: <20170828064959.580830286@linutronix.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Ref=https://api.informationprotection.azure.com/api/72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=kys@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-08-28T07:35:50.3955468-07:00; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [2601:600:a280:46f0:b076:3b2a:409c:285e] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR21MB0748;6:QNLa/C7H1g9SEp7ImBxJME3oWMv+HWEw5MK0flA3tbPZaA5I3ZUH3FsbY76j6FFmNIbz7B6AW4gGraBpDc7A/c9kkd+ca0QGMPAiuioAJtTqIXFvCvn4JRVmJHp8K0pFgQjsXaZ+9GCm5wKZ2dkABFHbJIej/xK/4bkiLSQqQv1yd88ahlE57nEi2xfQ+Scw49Q8OQctRr2r848PztvhLhptpB4Z27jYGbQOZQOpvPoUFyJxNbQXWcIXfWkpKd0nPVZXgYh7SjUX6J0Sj7hMXUrX8tqvZ98c1MZ+MCiBvtB0/Dp/d5qIwneMOVmNsaHEuFUBrJVtcgxWhkbPwGsJCA==;5:1ayBXtAMStRpmXGUjFkHfg+IAQBhgRVO/b4limfenN6Y3JZTWVS9o7nI/Fw6qNcWSlM9nvc5BaiQj9LLPE44/TlEinyzccWwS2g1U6O5HOoWT66sR9h46p48y8RVWp4zMh88krsOsZmCjYQu3BJhZQ==;24:JOZp8pxV80zZcHBe/y37N+SQo2uBJyXRBXy98TQnn920Ok6v581tDaRGGumKQOUR4iIXLbVH43Gu4WgguAXeNg6g9yd1Or9L0t2OrCptKQM=;7:k6yAB2UvMm75jYzy2C/uvGw3U5KzExcwm+STg1ffHO5UuJSIh+s0vfjPe5uanKBOXbrEga7E8JJnR6TmTH4KlovlztIHrdZShCGpbOB1lkwmRKo3zUKbk/OPxNHOHdmvx/b4Db88czx4wuiwWyiZy7F2mnVxDhNyfQYLM1s5fCpqlZrMFCsoqGELklRF3+RUEU8UV97RHq8TrN7gJEQ4IEd9ApOGUd9HvBb6rd9q9bw= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: f0a82c55-d9c6-47f0-79dd-08d4ee221586 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:DM5PR21MB0748; x-ms-traffictypediagnostic: DM5PR21MB0748: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kys@microsoft.com; x-exchange-antispam-report-test: UriScan:(89211679590171)(9452136761055)(146099531331640); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR21MB0748;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR21MB0748; x-forefront-prvs: 0413C9F1ED x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(47760400005)(189002)(13464003)(199003)(377454003)(478600001)(54906002)(14454004)(99286003)(55016002)(53936002)(6506006)(5005710100001)(8990500004)(4326008)(102836003)(2950100002)(6116002)(3280700002)(53546010)(2906002)(10290500003)(97736004)(25786009)(6436002)(77096006)(9686003)(6246003)(3660700001)(229853002)(305945005)(7736002)(5660300001)(74316002)(86612001)(7696004)(86362001)(7416002)(189998001)(10090500001)(8936002)(54356999)(76176999)(68736007)(81166006)(81156014)(8676002)(33656002)(105586002)(106356001)(50986999)(101416001)(2900100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR21MB0748;H:DM5PR21MB0476.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2017 14:35:52.1953 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR21MB0748 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7SEa3Jd030883 > -----Original Message----- > From: Thomas Gleixner [mailto:tglx@linutronix.de] > Sent: Sunday, August 27, 2017 11:48 PM > To: LKML > Cc: Ingo Molnar ; Peter Anvin ; Peter > Zijlstra ; Andy Lutomirski ; > Borislav Petkov ; Steven Rostedt ; > Juergen Gross ; KY Srinivasan ; > Stephen Hemminger ; Boris Ostrovsky > > Subject: [patch V3 43/44] x86/idt: Simplify alloc_intr_gate > > The only users of alloc_intr_gate() are hypervisors, which both check the > used_vectors bitmap whether they have allocated the gate already. Move > that > check into alloc_intr_gate() and simplify the users. > > Signed-off-by: Thomas Gleixner > Reviewed-by: Juergen Gross > Cc: "K. Y. Srinivasan" Reviewed-by: K. Y. Srinivasan > Cc: Stephen Hemminger > Cc: Boris Ostrovsky > Cc: Juergen Gross > --- > arch/x86/kernel/cpu/mshyperv.c | 9 ++------- > arch/x86/kernel/idt.c | 6 +++--- > drivers/xen/events/events_base.c | 6 ++---- > 3 files changed, 7 insertions(+), 14 deletions(-) > > --- a/arch/x86/kernel/cpu/mshyperv.c > +++ b/arch/x86/kernel/cpu/mshyperv.c > @@ -59,13 +59,8 @@ void hyperv_vector_handler(struct pt_reg > void hv_setup_vmbus_irq(void (*handler)(void)) > { > vmbus_handler = handler; > - /* > - * Setup the IDT for hypervisor callback. Prevent reallocation > - * at module reload. > - */ > - if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors)) > - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, > - hyperv_callback_vector); > + /* Setup the IDT for hypervisor callback */ > + alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, > hyperv_callback_vector); > } > > void hv_remove_vmbus_irq(void) > --- a/arch/x86/kernel/idt.c > +++ b/arch/x86/kernel/idt.c > @@ -354,7 +354,7 @@ void set_intr_gate(unsigned int n, const > > void alloc_intr_gate(unsigned int n, const void *addr) > { > - BUG_ON(test_bit(n, used_vectors) || n < FIRST_SYSTEM_VECTOR); > - set_bit(n, used_vectors); > - set_intr_gate(n, addr); > + BUG_ON(n < FIRST_SYSTEM_VECTOR); > + if (!test_and_set_bit(n, used_vectors)) > + set_intr_gate(n, addr); > } > --- a/drivers/xen/events/events_base.c > +++ b/drivers/xen/events/events_base.c > @@ -1653,10 +1653,8 @@ void xen_callback_vector(void) > return; > } > pr_info("Xen HVM callback vector for event delivery is > enabled\n"); > - /* in the restore case the vector has already been allocated > */ > - if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, > used_vectors)) > - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, > - xen_hvm_callback_vector); > + alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, > + xen_hvm_callback_vector); > } > } > #else >