From patchwork Wed Aug 9 01:01:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Clark X-Patchwork-Id: 9889383 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 1439160317 for ; Wed, 9 Aug 2017 01:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 045972891E for ; Wed, 9 Aug 2017 01:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECD1B289E4; Wed, 9 Aug 2017 01:11:45 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 75D5F2891E for ; Wed, 9 Aug 2017 01:11:45 +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 1dfFUi-0000N5-7H; Wed, 09 Aug 2017 01:09:08 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfFUh-0000Mz-2u for xen-devel@lists.xenproject.org; Wed, 09 Aug 2017 01:09:07 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 15/1F-01987-DFE5A895; Wed, 09 Aug 2017 01:01:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMXThEd0/cV2 RBjeWyVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkb9x5jLjjKVzFl8zL2BsYGni5GLg4hgZmM Ek9ndrKBOCwC91kkNk/vZAVxJAR+s0hs+LGXuYuRE8gpkpizezs7hF0icfnYVxYQm1dAUOLkz CdANgfQKE+Jrm2SIGE2AXOJ9X07GEFsFgEViVlPNrFBlAdILLm/hQnEFhYIlZjYuRJspIiAks S9VZPB4swCOhLH595khrA1JVq3/2afwMg3C8m2WUhSCxiZVjFqFKcWlaUW6Rqa6yUVZaZnlOQ mZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBAYWAxDsYHx52vMQoyQHk5Io7ybtzkghvqT8lMqM xOKM+KLSnNTiQ4wyHBxKEry/Y7sihQSLUtNTK9Iyc4AhDpOW4OBREuFNAEnzFhck5hZnpkOkT jEac1y5su4LE8eUA9u/MAmx5OXnpUqJ8+4DKRUAKc0ozYMbBIu9S4yyUsK8jECnCfEUpBblZp agyr9iFOdgVBLmXQwyhSczrwRu3yugU5iATonw7QQ5pSQRISXVwBgbUNi9+vmpSQVWenc+qVv u+eKusTxEesY2TRElltjv1/wa7vUYbP6SFbpDW2BN16bORJ0VX+a/fGRxWHojs8kc0yJD85V7 19ZmSFXskU0sWqz3fKN11YprHUa7+nd1LdzP807CuCbF3nyhD9PWf9G3+Hmrb7P6uv3+vKOzM CvPxYO7/UjUQyWW4oxEQy3mouJEABp3Epa4AgAA X-Env-Sender: christopher.w.clark@gmail.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1502240507!101569473!1 X-Originating-IP: [209.85.161.196] X-SpamReason: No, hits=0.3 required=7.0 tests=RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4517 invoked from network); 9 Aug 2017 01:01:48 -0000 Received: from mail-yw0-f196.google.com (HELO mail-yw0-f196.google.com) (209.85.161.196) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Aug 2017 01:01:48 -0000 Received: by mail-yw0-f196.google.com with SMTP id u207so3495726ywc.0 for ; Tue, 08 Aug 2017 18:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=cViLYZxyvocQqXXshb7M5IkVXQzqhkRBwhCpZtyzozo=; b=dWXKqFM56uZJHruqsCbbku44qFFLN02QwztolbqTY3ZJRtJlhFipq6tmjuqzWiANid nfrtSagKOVQBi5drD8QvbzWzshQacPjv0xsArTsQeRRCQwHPlkrspQQRKFT4bO9OhSK4 oeTTjinWlMr6sCgdpOTRvHvaNXoR9UQWf/Q7nwOcBblz/p6Nc7ER90EBOsh1H+CUlEoa a1LQJYzNd0bcigUJYkpijEVTR9uvs8+A5bKKccUCavj7S2I+D30JW0wGwNB+DJeQIsab 5HzCA+oS19ecrEjBD6Lq85Azjo4O4oUSkAmwVMTK5dIoWnRvzT5EXReU7XfSzewjlMqW ctcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=cViLYZxyvocQqXXshb7M5IkVXQzqhkRBwhCpZtyzozo=; b=slHW0ytID4JYAd7yQHNXu3Ru4Ke7KjgXITsF/WzCCYpDFEv4gFHZoYN6IM637ASfdu +9V3z/viqqjioI7TQA4EZRF16fZ3XxzRqnGkYL90caCml7gic23c/3pTsM1kaPY7RJOP oaPcFpWMmKqQo9cXaEw9dJICOo82kog2zbXTQ0lXYYKFPbjcQuJJE40fFBR/9shI0I4/ VrZOsDNXRbFnJVEbr9Nkb2ybg9gYgl95FRRQoxh3jAo5AC4Nb4lt1UANxnjQWUR5Tz8k KhPmr3E4KeWrn+ajSlqquDlMHU9sWmHlbk0cLQzu16W9IQUw6dCJyMLOiDg1eDEkrXas wdDQ== X-Gm-Message-State: AHYfb5hzzHevNA+JMjTYUE57IQFMclbtHPrgrDvRz327scGZG6biQC+2 fNLmsabdn3yt/98/YoC28RcgjGpc96TIink= X-Received: by 10.37.194.130 with SMTP id s124mr4828562ybf.360.1502240506874; Tue, 08 Aug 2017 18:01:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.172.25 with HTTP; Tue, 8 Aug 2017 18:01:46 -0700 (PDT) From: Christopher Clark Date: Tue, 8 Aug 2017 18:01:46 -0700 Message-ID: To: xen-devel@lists.xenproject.org Cc: shane.wang@intel.com, gang.wei@intel.com Subject: [Xen-devel] [PATCH] x86/tboot: tboot_shutdown: disable interrupts after map_pages_to_xen 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 Move the point where interrupts are disabled in tboot_shutdown to slightly later, to after the call to map_pages_to_xen. This patch originated in OpenXT with the following report: "Disabling interrupts early causes debug assertions. This is only seen with debug builds but since it causes assertions it is probably a bigger problem. It clearly says in map_pages_to_xen that it should not be called with interrupts disabled. Moved disabling to just after that call." The Xen code comment ahead of map_pages_to_xen notes that the CPU cache flushing in map_pages_to_xen differs depending on whether interrupts are enabled or not. The flush logic with interrupts enabled is more conservative, flushing all CPUs' TLBs/caches, rather than just local. This is just before the tboot memory integrity MAC calculation is performed in the case of entering S3. Original patch author credit: Ross Philipson. Signed-off-by: Christopher Clark Reviewed-by: Jan Beulich --- xen/arch/x86/tboot.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index cc26821..59d7c47 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -341,8 +341,6 @@ void tboot_shutdown(uint32_t shutdown_type) g_tboot_shared->shutdown_type = shutdown_type; - local_irq_disable(); - /* Create identity map for tboot shutdown code. */ /* do before S3 integrity because mapping tboot may change xenheap */ map_base = PFN_DOWN(g_tboot_shared->tboot_base); @@ -357,6 +355,10 @@ void tboot_shutdown(uint32_t shutdown_type) return; } + /* Disable interrupts as early as possible but not prior to */ + /* calling map_pages_to_xen */ + local_irq_disable(); + /* if this is S3 then set regions to MAC */ if ( shutdown_type == TB_SHUTDOWN_S3 ) {