From patchwork Wed May 25 15:00:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9135675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 61529607D7 for ; Wed, 25 May 2016 15:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51D0A28123 for ; Wed, 25 May 2016 15:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 435DA282B3; Wed, 25 May 2016 15:04:32 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 77DA828164 for ; Wed, 25 May 2016 15:04:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5aIs-0003pA-2p; Wed, 25 May 2016 15:00:58 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5aIq-0003ou-U1 for xen-devel@lists.xenproject.org; Wed, 25 May 2016 15:00:57 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id CF/17-19890-82EB5475; Wed, 25 May 2016 15:00:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRWlGSWpSXmKPExsXS6fjDS1d9n2u 4weNLihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bvwrVsBe3SFV+W/mVuYLwh2sXIySEkkCcx de9nNhCbV8BOYv2kK2C2hIChxL75q8BsFgFVid5V59lBbDYBdYm2Z9tZuxg5OEQEDCTOHU0CC TMLBErcuj+DESQsLGAjsa4tEsTkFRCU+LtDGKLCTuJZ03mWCYxcsxAys5BkIGwtiYe/bkHZ2h LLFr5mBilnFpCWWP6PAyLsIDGvYysrqhIQ21viz4S1bAsYOVYxqhenFpWlFuka6yUVZaZnlOQ mZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBAYeAxDsYOz453SIUZKDSUmU98ka13AhvqT8lMqM xOKM+KLSnNTiQ4waHBwC23atvsAoxZKXn5eqJMH7cg9QnWBRanpqRVpmDjA2YEolOHiURHh19 wKleYsLEnOLM9MhUqcYFaXEed+A9AmAJDJK8+DaYPF4iVFWSpiXEegoIZ6C1KLczBJU+VeM4h yMSsK8YiDjeTLzSuCmvwJazAS02P+LM8jikkSElFQDo/fKW/2ZYd9N76zb67WYu3V5UP6SNDP 135/5/6r7JidFZS1b5dkQvjJEIrxWZm3rVJ1rv8KWp9s63LW525Dw8t+J1+cVuFYwqU2a3MRY qMjCsr2lU7apY2eJh2KAj6vUsSf1az/ua3qSfvPs2/DT5/OsKwJSiixF7hn+mrY2u1Rmo28At 3ynEktxRqKhFnNRcSIAv8SODcICAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1464188453!15833805!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12218 invoked from network); 25 May 2016 15:00:55 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-8.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 May 2016 15:00:55 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 25 May 2016 09:00:52 -0600 Message-Id: <5745DA4102000078000EEBF5@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 25 May 2016 09:00:49 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper , Wei Liu Subject: [Xen-devel] [PATCH] x86/compat: correct SMEP/SMAP NOPs patching X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Correct the number of single byte NOPs we want to be replaced in case neither SMEP nor SMAP are available. Also simplify the expression adding these NOPs - at that location . equals .Lcr4_orig, and removing that part of the expression fixes a bogus ".space or fill with negative value, ignored" warning by very old gas (which actually is what made me look at those constructs again). Signed-off-by: Jan Beulich x86/compat: correct SMEP/SMAP NOPs patching Correct the number of single byte NOPs we want to be replaced in case neither SMEP nor SMAP are available. Also simplify the expression adding these NOPs - at that location . equals .Lcr4_orig, and removing that part of the expression fixes a bogus ".space or fill with negative value, ignored" warning by very old gas (which actually is what made me look at those constructs again). Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -175,7 +175,7 @@ compat_bad_hypercall: ENTRY(compat_restore_all_guest) ASSERT_INTERRUPTS_DISABLED .Lcr4_orig: - .skip (.Lcr4_alt_end - .Lcr4_alt) - (. - .Lcr4_orig), 0x90 + .skip .Lcr4_alt_end - .Lcr4_alt, 0x90 .Lcr4_orig_end: .pushsection .altinstr_replacement, "ax" .Lcr4_alt: @@ -200,7 +200,8 @@ ENTRY(compat_restore_all_guest) jne 1b .Lcr4_alt_end: .section .altinstructions, "a" - altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_ALWAYS, 12, 0 + altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_ALWAYS, \ + (.Lcr4_orig_end - .Lcr4_orig), 0 altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_SMEP, \ (.Lcr4_orig_end - .Lcr4_orig), \ (.Lcr4_alt_end - .Lcr4_alt) Reviewed-by: Wei Liu Reviewed-by: Andrew Cooper --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -175,7 +175,7 @@ compat_bad_hypercall: ENTRY(compat_restore_all_guest) ASSERT_INTERRUPTS_DISABLED .Lcr4_orig: - .skip (.Lcr4_alt_end - .Lcr4_alt) - (. - .Lcr4_orig), 0x90 + .skip .Lcr4_alt_end - .Lcr4_alt, 0x90 .Lcr4_orig_end: .pushsection .altinstr_replacement, "ax" .Lcr4_alt: @@ -200,7 +200,8 @@ ENTRY(compat_restore_all_guest) jne 1b .Lcr4_alt_end: .section .altinstructions, "a" - altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_ALWAYS, 12, 0 + altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_ALWAYS, \ + (.Lcr4_orig_end - .Lcr4_orig), 0 altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_SMEP, \ (.Lcr4_orig_end - .Lcr4_orig), \ (.Lcr4_alt_end - .Lcr4_alt)