From patchwork Tue Mar 24 19:15:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46280 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA57621596 for ; Tue, 24 Mar 2015 19:16:12 +0000 (UTC) Received: by lamq1 with SMTP id q1sf399025lam.3 for ; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=uFLLVf4UduXizePhA/iyEZHWhrUG6LfwKESyKQpy7Jw=; b=lLt4qCRh03rMvo7VEqoxnLTQUsXNvFezbJiD9abLH1JQ/0hKDvTKifbNw9Pc2rwyfV KLW5DMT/xJNXQciWu5fYYelLDeuHznRTHF2cRUDcH0455i2Un3nOsQpVZVrW7unmgpxV 1bN2UsZCqxn6XBRDpvMOIqbAvNgMKxFjMWGjh6zlCG3KDcr9/px3PFxLQap+CLUZdOUJ npEoH8cIN+ixuTO75+1snLPy83XMFDtDyKYjiu2LP+JqsSJFAHqMFOio7nctqaDrJpGW eH/53CCz5mERtPTJjnEZcpBT00ZFs5Vh9KMLJns4P+9TqrQ/u0aL9Se37/yExcJQrIoq 1/lg== X-Gm-Message-State: ALoCoQn5RKtgkvKDn7I/i0NvIZpxD1FW16h/wyd34OR1x2N4PJ11Sr476oXbz8s8iWmoxrxF9u9y X-Received: by 10.180.81.134 with SMTP id a6mr3438319wiy.1.1427224571816; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.199 with SMTP id s7ls7441laj.57.gmail; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) X-Received: by 10.152.28.5 with SMTP id x5mr4999983lag.112.1427224571653; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id d7si133091lbb.40.2015.03.24.12.16.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2015 12:16:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labe2 with SMTP id e2so2080662lab.3 for ; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) X-Received: by 10.152.178.197 with SMTP id da5mr5265874lac.56.1427224571426; Tue, 24 Mar 2015 12:16:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1648003lbq; Tue, 24 Mar 2015 12:16:10 -0700 (PDT) X-Received: by 10.50.25.225 with SMTP id f1mr24218880igg.29.1427224570246; Tue, 24 Mar 2015 12:16:10 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id f184si172559iof.16.2015.03.24.12.16.08 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Mar 2015 12:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YaUIy-0003Yn-9X; Tue, 24 Mar 2015 19:16:00 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YaUIx-0003Yh-Qs for edk2-devel@lists.sourceforge.net; Tue, 24 Mar 2015 19:15:59 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.180 as permitted sender) client-ip=209.85.212.180; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f180.google.com; Received: from mail-wi0-f180.google.com ([209.85.212.180]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YaUIw-0003Gy-V1 for edk2-devel@lists.sourceforge.net; Tue, 24 Mar 2015 19:15:59 +0000 Received: by wibdy8 with SMTP id dy8so83463026wib.0 for ; Tue, 24 Mar 2015 12:15:53 -0700 (PDT) X-Received: by 10.180.8.98 with SMTP id q2mr30270117wia.80.1427224552933; Tue, 24 Mar 2015 12:15:52 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.5.10]) by mx.google.com with ESMTPSA id eo1sm824517wib.16.2015.03.24.12.15.50 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Mar 2015 12:15:52 -0700 (PDT) From: Ard Biesheuvel To: lersek@redhat.com, ian.campbell@citrix.com, julien.grall@linaro.org, edk2-devel@lists.sourceforge.net Date: Tue, 24 Mar 2015 20:15:43 +0100 Message-Id: <1427224544-29955-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1427224544-29955-1-git-send-email-ard.biesheuvel@linaro.org> References: <1427224544-29955-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YaUIw-0003Gy-V1 Cc: stefano.stabellini@eu.citrix.com Subject: [edk2] [PATCH 2/3] Ovmf: XenHypercallLib: add explicit cache maintenance X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This library may be used with the caches and MMU off, while the hypervisor has the caches enabled. So add explicit cache maintenance to deal with the potential incoherency. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- OvmfPkg/Library/XenHypercallLib/XenHypercall.c | 15 +++++++++++++++ OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf | 3 +++ 2 files changed, 18 insertions(+) diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c index ecc757cf707c..00ba9e64b406 100644 --- a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c +++ b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c @@ -20,6 +20,7 @@ #include #include +#include UINT64 XenHypercallHvmGetParam ( @@ -31,6 +32,13 @@ XenHypercallHvmGetParam ( Parameter.domid = DOMID_SELF; Parameter.index = Index; + + // + // We may be running with the MMU and caches off, so invalidate any copies + // of Parameter in the cache before passing it to the hypervisor. + // + InvalidateDataCacheRange (&Parameter, sizeof(Parameter)); + Error = XenHypercall2 (__HYPERVISOR_hvm_op, HVMOP_get_param, (INTN) &Parameter); if (Error != 0) { @@ -39,6 +47,13 @@ XenHypercallHvmGetParam ( Error, Index)); return 0; } + + // + // We may be running with the MMU and caches off, so force the updated + // Parameter to be visible in main memory. + // + WriteBackDataCacheRange (&Parameter, sizeof(Parameter)); + return Parameter.value; } diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf b/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf index f4503a4b01f4..8175ba6d3186 100644 --- a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf +++ b/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf @@ -62,5 +62,8 @@ HobLib DebugLib +[LibraryClasses] + CacheMaintenanceLib + [Guids.IA32, Guids.X64] gEfiXenInfoGuid