From patchwork Wed May 1 04:22:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 10924455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BEF4912 for ; Wed, 1 May 2019 04:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 883EF28D23 for ; Wed, 1 May 2019 04:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C2CA28D2A; Wed, 1 May 2019 04:25:29 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2906928D23 for ; Wed, 1 May 2019 04:25:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLglo-0005WM-NM; Wed, 01 May 2019 04:23:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLgln-0005WH-33 for xen-devel@lists.xenproject.org; Wed, 01 May 2019 04:22:59 +0000 X-Inumbo-ID: c9cedbd0-6bc8-11e9-9070-f77e1e4dfa56 Received: from mail-io1-f66.google.com (unknown [209.85.166.66]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c9cedbd0-6bc8-11e9-9070-f77e1e4dfa56; Wed, 01 May 2019 04:22:53 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id v9so14066157iol.10 for ; Tue, 30 Apr 2019 21:22:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Pnkx+/EayRNj/o1kXOQxCwA7dIdk8c7+CV+voWvkCiA=; b=aVlR4qyw+wvXK6FB8+X7UA4EixF4QMPUnpMlsZLB5PdEH6Ied4YV0K+I5ubFG6QvK6 s0nm1MIAux8shpzNJlYhy3JJbtkgPB1hBRfgT2L6uUptJofKVWtsbaQDMWkSaETtCEAt llDRUhs0bd+3GLR/OO0ASVKkpug3lOkJsieC21fYgqoY9IaTdnbGCtD51MxWVdA6zMx4 oUD7c6jFBKS6cuxxsHnROF+it4S6dbignN//O15vP6hEjzFM247+hGx/wRhEyJbGHjvb II6iddsuVtaLI7VxZXscocizwenHEoTMFeHyqWAvNhlR2JZqscMWibe4HCIsOiNGrYh4 G+ZA== X-Gm-Message-State: APjAAAUYuCSwiZ5moij718/FPSLBf8YWkWEG9bDrT5X3PKT4SlYCyosv BtaNDnqCvqkvhImvGmXNZYK9f9ol X-Google-Smtp-Source: APXvYqxoy8HtLNRpUT7CHcbGdbTCdx4qe9j9SRZKGoHq8CKeDPZt97+JfQHq6yRg95NoOBIo50t+Ww== X-Received: by 2002:a5e:9203:: with SMTP id y3mr43803565iop.22.1556684572863; Tue, 30 Apr 2019 21:22:52 -0700 (PDT) Received: from localhost.localdomain (c-71-205-12-124.hsd1.co.comcast.net. [71.205.12.124]) by smtp.gmail.com with ESMTPSA id e15sm7703351ios.19.2019.04.30.21.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 21:22:51 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 22:22:49 -0600 Message-Id: <20190501042249.1218-1-tamas@tklengyel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/vm_event: correctly gather gs_shadow value X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Tamas K Lengyel , Wei Liu , Razvan Cojocaru , Andrew Cooper , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently the gs_shadow value is only cached when the vCPU is being scheduled out by Xen. Reporting this (usually) stale value through vm_event is incorrect, since it doesn't represent the actual state of the vCPU at the time the event was recorded. This prevents vm_event subscribers from correctly finding kernel structures in the guest when it is trapped while in ring3. Signed-off-by: Tamas K Lengyel Cc: Razvan Cojocaru Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: Roger Pau Monne Acked-by: Razvan Cojocaru Reviewed-by: Andrew Cooper --- xen/arch/x86/vm_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index 51c3493b1d..4464940da7 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -239,7 +239,7 @@ void vm_event_fill_regs(vm_event_request_t *req) vm_event_pack_segment_register(x86_seg_ds, &req->data.regs.x86); vm_event_pack_segment_register(x86_seg_es, &req->data.regs.x86); - req->data.regs.x86.shadow_gs = ctxt.shadow_gs; + req->data.regs.x86.shadow_gs = rdgsshadow(); req->data.regs.x86.dr6 = ctxt.dr6; #endif }