From patchwork Thu Nov 23 18:31:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119531 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172939edl; Thu, 23 Nov 2017 10:34:11 -0800 (PST) X-Google-Smtp-Source: AGs4zMbUbpFEfGDqTFHcmyTglrOX71Jeu6Bow4Lm3Y2j1OjkDW3oB2qaeJlP77c5fZdPYBhroGAX X-Received: by 10.36.188.195 with SMTP id n186mr12587570ite.139.1511462051718; Thu, 23 Nov 2017 10:34:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462051; cv=none; d=google.com; s=arc-20160816; b=uMg02RKclJTbY46A3jRUgISTwrPJfYQn8fr84bmrDtL7zEuNCz56gWD1yJQVD5wZDC F28aQ9TDY+iAjFnL+M5XI4Ly6WmA1VBA6W26rL3mnZf/LtE9RvmoxEDVVodOABgbZbcY 2EDT5P4XE6vCfX06KALz9xX6/bnuxDgU7LrjWFQCbt7nQZNUmmVxenrDdzWEp1MUpZA1 /IujtH8WLO676/ILRlBp0/PjyueJrsprjWwUtv8LDwU6s0yWZxxZ9M6/SSe+63d2tp1F KtwkIsX2wdNq52aC/qwezSXJEx/ymNvoP09lBIkAW6rVXf0g7pq/V0lTqCwSJbb92EFi H8Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Y0Y5qxyE7Pk9rv/XfxbR7euY6Aluy0/P4l7B4JoVcrY=; b=a7XHVfiRIDE/w773DaPQ7IRqgRFB7mK7j8860AKG2uV5VhFOaw2B+cvzdz4gUnA3yX AmO2xg/as6eAxA9eGrYdTqLQz26j6a1hzPnsS0eG5VhchFMXmSeXmo5NU1NmJtgU79UG 4yjhmCEzj1MMI8RgGupQou2FPuSOd5HOMv2Ven0HNNsLAu0v8ZZtKJriERWf4DPzGWvH MzPTLgM7QYweetRrpdJpPXp7Lx/8yUin69XowtF+/dtPr72qS4dXjas0hn6T/0XSnReE Gb+0IoyLfhsAbtZCgaIVSvhwFMHe1/XGsI7+eH1thfBDOYtFDdy1/1WgUtVNIkH+anjO Xjhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UVS7XbrE; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x187si6783443itb.32.2017.11.23.10.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UVS7XbrE; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIM-00059X-92; Thu, 23 Nov 2017 18:32:18 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIL-00059B-I1 for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:17 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id A8/C0-27451-034171A5; Thu, 23 Nov 2017 18:32:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMbThsK6BiHi UwdFVihZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bjxtdMBWt5K562PWNpYGzk6mLk4hASmMwo cb9tCQuIwyIwj1ni+a9ONhBHQqCfVeLvvk+MXYwcQE6exK6tGhBmmsSK5eldjJxAZpXEzRNL2 UHCQgJqEmveREHM7GOSuPu5nwkkziagI7FuRi1IuYiAtMS1z5cZQWxmgXiJx1Ovs4HYwkD2tM kNYDaLgKpEb/NZMJtXwEbi9IP/zBCr5CV2tV1kBbE5BWwljh74wAyx1kbi82fFCYyCCxgZVjF qFKcWlaUW6Rob6CUVZaZnlOQmZuboGhqY6uWmFhcnpqfmJCYV6yXn525iBIZaPQMD4w7GCav8 DjFKcjApifLK/BKLEuJLyk+pzEgszogvKs1JLT7EKMPBoSTBu0JIPEpIsCg1PbUiLTMHGPQwa QkOHiUR3u0gad7igsTc4sx0iNQpRnuOC3cu/WHiOLDnFpB8NvN1AzPHtKutTcxCLHn5ealS4r ybQdoEQNoySvPghsKi9BKjrJQwLyMDA4MQT0FqUW5mCar8K0ZxDkYlYd5NIFN4MvNK4Ha/Ajq LCeisn8eFQc4qSURISTUw9hhtc76yovTarF/V4bpP9+qUPzQOMVpgYFVoK860TuOm0rHNthwX fi39tvH0P6ukr4XGCbt9IpdOz5uosoevIbnw8k6ve5OSrT0TOSY9NDXP7viyXUBBbuayhBd6I oHCfCeb57Qeyr0uVNl5VnJZ9PtTUorS51XN5dK9S/KfHJ8b/MivpyxKiaU4I9FQi7moOBEAv8 aXBc0CAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-4.tower-206.messagelabs.com!1511461936!108519832!1 X-Originating-IP: [209.85.128.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19105 invoked from network); 23 Nov 2017 18:32:16 -0000 Received: from mail-wr0-f195.google.com (HELO mail-wr0-f195.google.com) (209.85.128.195) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:16 -0000 Received: by mail-wr0-f195.google.com with SMTP id l22so18297808wrc.11 for ; Thu, 23 Nov 2017 10:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sPc/WkwHtIqcBaq/uRsdk4ZUhTlCkFbM3t5zmT4y8y0=; b=UVS7XbrEZX0ySbhLZviuAXmb6MoVNacm/jBWAXqcUEMdUPT4cX46M+qFsygEoE6JO9 ttkyb6xg2K23ndA6rg4QfQEsVmY5SAS4GxRgF9A9IH2bsaoZ/I7UIjk3oNXSBpU24udr azZuseykjykVbAECylXsUyL5vMh+3oCJdjz30= 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:in-reply-to :references; bh=sPc/WkwHtIqcBaq/uRsdk4ZUhTlCkFbM3t5zmT4y8y0=; b=X0V2stO4BbK75sgi4q9HE4dtGlWKSwSjuYO5CSdQm4ozZ64TUuak+523bQLwS683lr ksorfwCyp88uY1D4WrTp+4o1d2UqUQ74AJSdtf/0mEI3vxQndCFRizGBfNR1kZHnadql 30hKZIuYopAWMY5wigpsGvE1O/ot5TjKDptks5kqFBEpvT3TA8faEYuJG1tK9+/bQNim p3KEMM3yfoy5Ha4GFdY4gZCooLL+YTuqOvxfIHxH2E9AxZzazuB0pH0U7HpHm57MPKUq FDALJcLh0EX8grwQXRsSWzm/3f06gTF04XzKtOEN/6MdrXUS43ChBewh5+r3gRo290+0 xJ3g== X-Gm-Message-State: AJaThX4p8D0kSA7HZW5oXJ1CEbJrAQt6e1aKlpgZcJwsaPvR25OjTMay ZxNGvInretiEVUPSxjlD60Bv+Bfwqps= X-Received: by 10.223.182.73 with SMTP id i9mr23107650wre.113.1511461936012; Thu, 23 Nov 2017 10:32:16 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:15 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:31:55 +0000 Message-Id: <20171123183210.12045-2-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 01/16] xen/arm: raw_copy_to_guest_helper: Rename flush_dcache to flags X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In a follow-up patch, it will be necessary to pass more flags to the function. Rename flush_dcache to flags and introduce a define to tell whether the cache needs to be flushed after the copy. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/guestcopy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 4ee07fcea3..2620e659b4 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -5,8 +5,10 @@ #include #include +#define COPY_flush_dcache (1U << 0) + static unsigned long raw_copy_to_guest_helper(void *to, const void *from, - unsigned len, int flush_dcache) + unsigned len, int flags) { /* XXX needs to handle faults */ unsigned offset = (vaddr_t)to & ~PAGE_MASK; @@ -24,7 +26,7 @@ static unsigned long raw_copy_to_guest_helper(void *to, const void *from, p = __map_domain_page(page); p += offset; memcpy(p, from, size); - if ( flush_dcache ) + if ( flags & COPY_flush_dcache ) clean_dcache_va_range(p, size); unmap_domain_page(p - offset); @@ -50,7 +52,7 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned len) { - return raw_copy_to_guest_helper(to, from, len, 1); + return raw_copy_to_guest_helper(to, from, len, COPY_flush_dcache); } unsigned long raw_clear_guest(void *to, unsigned len) From patchwork Thu Nov 23 18:31:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119528 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172889edl; Thu, 23 Nov 2017 10:34:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMbh0tE1Hjr1tVaELo7w0IP/vie/Ui+5bREjJ8QzlLxjBn8xVLZqphgIW+JukVKiungjz0n3 X-Received: by 10.36.67.141 with SMTP id s135mr13124952itb.142.1511462048266; Thu, 23 Nov 2017 10:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462048; cv=none; d=google.com; s=arc-20160816; b=Q3BGrg2iRBVMwFw+iDaHP7/re0Qu9Sb75kg8eW/h+7Lq15Jckc8N6j1IHvlU5trdEB rLZ/3ErCriFAT+nFOgqgqTCZrKTVRkIk44rbuYV3ofmP4o0VI1puCcIa1uKOiQbXsHrT E+LRu3J9C5B0KEFRq4zLVPDw9gdf46G20aUCXLkmccFB1szyBt+OPTOYFfYaoRf5KDaU LjG4tDIF55yCmq8XOM3l0Am5PwBHp72cmbxvY5+nISNcQRd/FsEeuyb2KXoMdf0VcDRV sZjIUKG4Mq4EVhPHRceM1W3DSJWoVDvtDIwi7vg9PrsPNSkgqwG/NqlyJ77mB4riLpLv S1kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=gJOej5Mcs2ik7pwKRdhZI7X03RIAXAmc8gNxRUiXMpQ=; b=WpXyLMyK0/TSzjUTNUUdQFplV1Qv/DveAv2UQQEN8Ioma4zJJJuDh97kwVXQ73eOfI eUSpADSyu6fGrbqLp0DW0lEYEgNJNhFPfmazqtrwr50UypjwtKLxAVl8A+AYW/dZAA3l G4jGBEL7LHCgYlhcvPT3WsjW3KyYKBpcCHq1Ld/diMiGE2bKlo1Pgu2gQ+mK4o1B4lk9 vfPpRp1sZJh3qdpd39CIir3VrCrmy9bbB/6oyHmHCTC8oi1hMLvbwv03hPLLN52QSzCv tGV83AO8IoUQdzT5TW3DJekcO1+Pp/I/ox0DVXHlAdOiPeXvbh6nHECMmhAoOvfaPBxl zRqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ekr5ivJQ; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r132si6826015itd.130.2017.11.23.10.34.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ekr5ivJQ; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIO-00059p-G1; Thu, 23 Nov 2017 18:32:20 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIN-00059i-K0 for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:19 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 59/BD-27709-234171A5; Thu, 23 Nov 2017 18:32:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsXiVRvkomskIh5 lcH81v8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnFk3SW2gpniFbsedrI3MK4X7GLk4hASmMgo 8adrPjOIwyIwj1li3beXbCCOhEA/q8SC1c1AGU4gJ0/i8axDbBB2msSTxnOsEHaZxI8PT1m6G DmARqlJrHkTBTG1j0li0rQbjCBxNgEdiXUzakHKRQSkJa59vswIYjMLxEs8nnqdDaREWCBVYt cLR5Awi4CqxNsdn8G28grYSNzoW8gCsUleYlfbRbCtnAK2EkcPfGCG2Goj8fmz4gRGwQWMDKs YNYpTi8pSi3SNjPSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQKDjQEIdjCumR94 iFGSg0lJlFfml1iUEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleSWHxKCHBotT01Iq0zBxg2MOkJ Th4lER4twsBpXmLCxJzizPTIVKnGC059u259YeJ49nM1w3MHNOutjYxC7Hk5eelSonzbgZpEA BpyCjNgxsHi81LjLJSwryMQAcK8RSkFuVmlqDKv2IU52BUEuZ9CzKFJzOvBG7rK6CDmIAO+nl cGOSgkkSElFQDY1lw/k+rPTrn1qd8UuBmU8+vjZPKC9me5fpuXwz3U39m177VnQKJtaoBaufN WLsXf1V5un+7Xd/UPcGXd2/oPvmlz3xy/d/VU9u3+84L3VYmce+wdYHLzNe6t//1Tyh/y5LqK /7gzc2dXU19z3qahO9P2OLNJv2N5auq1qIc04mvOk8UNOV3K7EUZyQaajEXFScCACizZMfIAg AA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1511461938!108371521!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42653 invoked from network); 23 Nov 2017 18:32:18 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:18 -0000 Received: by mail-wm0-f68.google.com with SMTP id x63so18277985wmf.4 for ; Thu, 23 Nov 2017 10:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bEn/HbrpaommqdGvd4y/dBAcNC03JToYhk7ZLxmAju4=; b=Ekr5ivJQkxT5lWBH/DwxtKpu/90gbPlZ9+YjEApVDmGxUI40tTuI/ALWNi4LOX/6gN ISlekP6gtY6h0eYUmD0PleDNaofUpVikTwuYzqG3HyhCsrHR1SmECf+MCZxptk0NnLnq uy6bOWqLQDz8DH/Zy807OdlMvtJpIrAcyTWEg= 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:in-reply-to :references; bh=bEn/HbrpaommqdGvd4y/dBAcNC03JToYhk7ZLxmAju4=; b=iJCARLTEKxarxk/uYo9ND7Bk3/pUSUffUvm1xIvI00dM7eMcBg6EQg51QDfQOwSRoZ 7/opheFtRmM08azi/og34BJna7kGOwu5x75CgsSv0p0DtcHh4a7vlIa9kWKNl4eNyNVh OeLAJKVi+VKrGkfCFiprpOa+Enmf5JtCJiARf3CFicC8cf6THN+tX+VkzcVca/0U98+v UVIyQDL+CHEMkwqVZOZSiuBS61KuUZGdt0VlN9VIwVpPB/1wUzg+qfVXgQECh+LwrHKB rFoElIoTn1T7M1SS34Nt2YTYk8TjsXLiIeYh6C55S3oia8gMdd5nk//X/L5GJvRc29F9 ql+w== X-Gm-Message-State: AJaThX4drIaZYZQQUhkk87R1toYBhJRIez8x3nVZ4okm84VdzaOiYS95 kOzV4IA56wJIl9dhTHE+l25J6UFx2PU= X-Received: by 10.28.8.80 with SMTP id 77mr7078485wmi.135.1511461937706; Thu, 23 Nov 2017 10:32:17 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:16 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:31:56 +0000 Message-Id: <20171123183210.12045-3-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 02/16] xen/arm: raw_copy_to_guest_helper: Rework the prototype and rename it X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" All the helpers within arch/arm/guestcopy.c are doing the same things: copy data from/to the guest. At the moment, the logic is duplicated in each helpers making more difficult to implement new variant. The first step for the consolidation is to get a common prototype and a base. For convenience (it is at the beginning of the file!), raw_copy_to_guest_helper is chosen. The function is now renamed copy_guest to show it will be a generic function to copy data from/to the guest. Note that for now, only copying to guest virtual address is supported. Follow-up patches will extend the support. Signed-off-by: Julien Grall --- xen/arch/arm/guestcopy.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 2620e659b4..d1cfbe922c 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -7,11 +7,11 @@ #define COPY_flush_dcache (1U << 0) -static unsigned long raw_copy_to_guest_helper(void *to, const void *from, - unsigned len, int flags) +static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, + unsigned int flags) { /* XXX needs to handle faults */ - unsigned offset = (vaddr_t)to & ~PAGE_MASK; + unsigned offset = addr & ~PAGE_MASK; while ( len ) { @@ -19,21 +19,21 @@ static unsigned long raw_copy_to_guest_helper(void *to, const void *from, unsigned size = min(len, (unsigned)PAGE_SIZE - offset); struct page_info *page; - page = get_page_from_gva(current, (vaddr_t) to, GV2M_WRITE); + page = get_page_from_gva(current, addr, GV2M_WRITE); if ( page == NULL ) return len; p = __map_domain_page(page); p += offset; - memcpy(p, from, size); + memcpy(p, buf, size); if ( flags & COPY_flush_dcache ) clean_dcache_va_range(p, size); unmap_domain_page(p - offset); put_page(page); len -= size; - from += size; - to += size; + buf += size; + addr += size; /* * After the first iteration, guest virtual address is correctly * aligned to PAGE_SIZE. @@ -46,13 +46,13 @@ static unsigned long raw_copy_to_guest_helper(void *to, const void *from, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) { - return raw_copy_to_guest_helper(to, from, len, 0); + return copy_guest((void *)from, (unsigned long)to, len, 0); } unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned len) { - return raw_copy_to_guest_helper(to, from, len, COPY_flush_dcache); + return copy_guest((void *)from, (unsigned long)to, len, COPY_flush_dcache); } unsigned long raw_clear_guest(void *to, unsigned len) From patchwork Thu Nov 23 18:31:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119536 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172988edl; Thu, 23 Nov 2017 10:34:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMar9fVti/NtaE1Q4vN4kYRsHZNriePcW2lfV68o/NAPqtP/GZPIO05c65hEGmJUUOymeHpf X-Received: by 10.107.88.9 with SMTP id m9mr10303821iob.68.1511462054644; Thu, 23 Nov 2017 10:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462054; cv=none; d=google.com; s=arc-20160816; b=Had8wgk5l+wlM98ph4YKdl9slv5zXor38rsQMvCHr5kvCkywX/2xG8/KLVEmmxnU4I VWA9eyUrujcp6MUFdVWWaSvnNqwRE6GG7k6xK4o+NPXmJhC6c9wgM1GXx/DNabGnVGZV c9bL3jhH83V2oUb1y8Zyn1YxJ85UNRDQeHgGQwA/9Y1PfAEs7rIYePLY7KB6T2I48cDH FSiLpx/NHpQgG9J3/XeNH7WFRu1WDvlTzZfyelzyLd5K9azTE/WZ1cQPeUyKfDzxMaSX Jaliuv+CME0ifMuvQIq3QzwDC60+Nx0acA3lYsuG02/TP0/7fvL99kku0Wc8oVEcY404 imig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=5/5WYGgDDEllG+8pXC5/4UdBQfPN9XQ1NjdK2qVgPjU=; b=vYYJdrPJKf3soKNW6m/412Wl4vuN2OZwX7iIB3giu2AmRm89JcwYYTJq832/qbUzCB OhivhXWJaCmZzNMOYhH+EvEXYliBL7JVcVgG2/PUtv2uO7oJvp9lUf8KM8cETQfgVvpT xY4V+yVnonSmI2ZSHlSb384egISjlidaxbTx3g8DKnElI0gfRTJWjvUq/nm4t3hSaEO0 jWpH0cD6sYeFdQLxgiVluqzyGCeE0a6OO7xQOaRZsmd6Fg7p65mMp2RArpZQ7XEKGrBf TpNF6gb9pv0ddMFMDL+ETWPzmtMFkjAD91gCmR8J7fOYYAcTiM7kEJOr1Uc1ur5I5hVF L0oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ixp7xlwa; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id a134si846819ita.169.2017.11.23.10.34.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ixp7xlwa; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIQ-0005BL-Qv; Thu, 23 Nov 2017 18:32:22 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIP-00059o-1b for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:21 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 6F/83-13440-334171A5; Thu, 23 Nov 2017 18:32:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsVyMbThkK6xiHi UQcdFToslHxezODB6HN39mymAMYo1My8pvyKBNWP+mgbWgg3SFc87NzI2ME4X6WLk4hASmMQo 0dMwnbmLkZODRWAes0RDnxZIQkKgn1Xi9r5drCAJCYE8iRfzNzJC2GkSJ47uhrKrJE797WXvY uQAmqQmseZNFMTQPiaJdxvXgcXZBHQk1s2oBSkXEZCWuPb5Mlgrs0C8xOOp19lAbGGBTImWSc 3sEDeoSmx60ga2llfARuLT4/XMEKvkJXa1XQSLcwrYShw98IEZYq2NxOfPihMYBRcwMqxi1Ch OLSpLLdI1stBLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAgMtnoGBsYdjO0n/A4x SnIwKYnyyvwSixLiS8pPqcxILM6ILyrNSS0+xCjDwaEkwesrLB4lJFiUmp5akZaZAwx7mLQEB 4+SCO92IaA0b3FBYm5xZjpE6hSjPceFO5f+MHEc2HMLSD6b+bqBmWPa1dYmZiGWvPy8VClxXk +QqQIgbRmleXBDYXF6iVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw71uQ5TyZeSVwu18BncU EdNbP48IgZ5UkIqSkGhiL5/kbZxgKOf19Ff76ddjO0OMKgl89Ypb/v7xN4NLTawL9136w+Acl JrhUz/B6J3m/bcdnveBqkWqf7BeMZ+J29sjM79lp2OoX+urkIY++LSdXhd1r6cz1nXvJLDpzc iqLYmINC1PrZKH1isX/bAIzPk/182OSezXN3HXWttctL1/yfpn2rVqJpTgj0VCLuag4EQBo1O KjzgIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1511461938!108759238!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14343 invoked from network); 23 Nov 2017 18:32:19 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:19 -0000 Received: by mail-wr0-f194.google.com with SMTP id k18so13374169wre.1 for ; Thu, 23 Nov 2017 10:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+q3cgWIse653ZY0dMk/l5QdcfE70HHh/XxgLEDBYGrc=; b=Ixp7xlwapDbCUMnVrALKp5NEVQULHA/1zGvuZA0ubVweZbl88tFXSYJTGfyOqaNHdT 9JRsJLIMmDjqjuf9u0WgCxJmEukFGqZUIZBf8kK2BpPLDzfyXHX+emIXtt7j3kjWxrxB XVwcTjFYmQCiZYliCtmTHZMtQkapjc1c85wvs= 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:in-reply-to :references; bh=+q3cgWIse653ZY0dMk/l5QdcfE70HHh/XxgLEDBYGrc=; b=hDhnT0WqW73P6kQZvPTicAywzxbQ9k4y7+vyqrE4Fr3CmNkNKRsOe3O+UJ+SQXt9k4 MSeh9OmqMlyv+Miko99qAs5WvVqdg8+mfSkAAZdGQfXz5P3qKgnGBqpSh4DsENqUqICG T1u1bK+kbElzluGCOSn2bC3ZBAQwk8hjZqdd9I1PW2yBaDJkajUhAEzAXmLbjIavM/dr SxQ3Nq/tP0jsdk9YUDPUIkioqRltf9hl4LbGQecYQfx1Tc61l36v6/TN/jVUX6iS1ju/ 4OlPOL7l9x1LmxgID6ITTwNX3IFwQM1eQxBFfdLLr6FsfovF5C3vKjJ+V9iKAJTyQRXk StgQ== X-Gm-Message-State: AJaThX7vd9R/i+VRbsVBczxvuLkYl94DHu0hN8KgVos6TnbNcsnLWwzB nUcfDCpUVPvNAkcPABxEsPCkmjlWdLY= X-Received: by 10.223.130.17 with SMTP id 17mr22616749wrb.131.1511461938527; Thu, 23 Nov 2017 10:32:18 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:18 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:31:57 +0000 Message-Id: <20171123183210.12045-4-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 03/16] xen/arm: Extend copy_to_guest to support copying from guest VA and use it X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The only differences between copy_to_guest (formerly called raw_copy_to_guest_helper) and raw_copy_from_guest is: - The direction of the memcpy - The permission use for translating the address Extend copy_to_guest to support copying from guest VA by adding using a bit in the flags to tell the direction of the copy. Lastly, reimplement raw_copy_from_guest using copy_to_guest. Signed-off-by: Julien Grall --- xen/arch/arm/guestcopy.c | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index d1cfbe922c..1ffa717ca6 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -6,6 +6,8 @@ #include #define COPY_flush_dcache (1U << 0) +#define COPY_from_guest (0U << 1) +#define COPY_to_guest (1U << 1) static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned int flags) @@ -19,13 +21,18 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned size = min(len, (unsigned)PAGE_SIZE - offset); struct page_info *page; - page = get_page_from_gva(current, addr, GV2M_WRITE); + page = get_page_from_gva(current, addr, + (flags & COPY_to_guest) ? GV2M_WRITE : GV2M_READ); if ( page == NULL ) return len; p = __map_domain_page(page); p += offset; - memcpy(p, buf, size); + if ( flags & COPY_to_guest ) + memcpy(p, buf, size); + else + memcpy(buf, p, size); + if ( flags & COPY_flush_dcache ) clean_dcache_va_range(p, size); @@ -46,13 +53,14 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) { - return copy_guest((void *)from, (unsigned long)to, len, 0); + return copy_guest((void *)from, (unsigned long)to, len, COPY_to_guest); } unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned len) { - return copy_guest((void *)from, (unsigned long)to, len, COPY_flush_dcache); + return copy_guest((void *)from, (unsigned long)to, len, + COPY_to_guest | COPY_flush_dcache); } unsigned long raw_clear_guest(void *to, unsigned len) @@ -90,35 +98,7 @@ unsigned long raw_clear_guest(void *to, unsigned len) unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len) { - unsigned offset = (vaddr_t)from & ~PAGE_MASK; - - while ( len ) - { - void *p; - unsigned size = min(len, (unsigned)(PAGE_SIZE - offset)); - struct page_info *page; - - page = get_page_from_gva(current, (vaddr_t) from, GV2M_READ); - if ( page == NULL ) - return len; - - p = __map_domain_page(page); - p += ((vaddr_t)from & (~PAGE_MASK)); - - memcpy(to, p, size); - - unmap_domain_page(p); - put_page(page); - len -= size; - from += size; - to += size; - /* - * After the first iteration, guest virtual address is correctly - * aligned to PAGE_SIZE. - */ - offset = 0; - } - return 0; + return copy_guest(to, (unsigned long)from, len, COPY_from_guest); } /* From patchwork Thu Nov 23 18:31:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119534 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172972edl; Thu, 23 Nov 2017 10:34:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMZmxU+yREygR8gN9Y6MymRPStumjK2E5iVIqZFYizru3swOuJaMCNkvzduy7hKsaU8nY0mE X-Received: by 10.36.154.71 with SMTP id l68mr12085993ite.57.1511462053416; Thu, 23 Nov 2017 10:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462053; cv=none; d=google.com; s=arc-20160816; b=uUP8qu+fkVJKG6B15mytFLP3jSz8L7I4IWV8z0uk5VOyvagy43FrZj26I//wVDInDh EKhYFv+Q6nnToIlI898IOud60xdffp2hVY5lN4w/4HOYayY9Wr3uRY/Fgu6vzqd5ndBG cvc1XgBKO4Ch5nm2IX73DLvITjVITCydb+QtzXcAcdIHw8B5GwyDNtTtCZQKN2p0DtoU 86QkDXnzWOfN//b+pJCZIO2xbNBpbshQqNZ6tn4t6xnf1Me9XQU9pVhyYMGL1n//2E2f oea55alGXjAXdLuFAbtNdIZS5en7hpwLJy9dM2/FRvaUjoyedhBGeVGR8z+qlWC6djQ9 GmUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=d0TmRE2xqp4KL82jEn8DNjqW8X+96ZBF7cnaWtaAEn8=; b=reY/nwf2a2vQQXPDZ4XgZY51lQ5x2vlbwKrctOV7srlM24iceFfjOOBuZqe6WwIhNA S5/oVLP0dnsTZf5aVc9tIWW/qFd4SaTo8RBphujwk90byU2rbAg+MhEwmOHw0xGZcxq5 Gfqz861PwgVzflhmEbbHH1S3+fySQzSg7NXihP2cXZpiPOPJKE4HJf+fUpRiJ/PmbXmf RtgbqDVXQHjMLWCZKBci+hQcMUwqIC1vbG8oa0/kj6vU52Yb6aJ7x/AS2l2L8ibOd4uO 7PGuJTryo2si5RtZw2jW+YLf8+Im4VL1MmFTxPYSXbUavbSFYXhLARd2oboz7igSQeh4 FOwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c3tGbLUj; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 203si10903398iou.284.2017.11.23.10.34.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c3tGbLUj; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIR-0005Bd-1r; Thu, 23 Nov 2017 18:32:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIP-0005A4-35 for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:21 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 94/FE-32540-434171A5; Thu, 23 Nov 2017 18:32:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVyMbThiK6xiHi UwewtJhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a0vk+sBcsEKw5P8G5gXMHTxcjFISQwmVGi +UA/E4jDIjCPWeLTlAWsII6EQD+rxJ4tj4EcDiAnT2LrAxMIM01i2X6JLkZOILNS4ufMV2wgY SEBNYk1b6IgZvYxSfx6+5wFJM4moCOxbkYtSLmIgLTEtc+XGUFsZoF4icdTr7OB2MICKRJbD+ 8Bi7MIqEo8nn4NbCSvgI3EuaYgiE3yErvaLrKC2JwCthJHD3xghthqI/H5s+IERsEFjAyrGNW LU4vKUot0zfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQKDjAEIdjDOvOx/iFGS g0lJlFfml1iUEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleSWHxKCHBotT01Iq0zBxguMOkJTh4l ER4twsBpXmLCxJzizPTIVKnGO05Lty59IeJ48CeW0Dy2czXDcwc0662NjELseTl56VKifNuBm kTAGnLKM2DGwqLz0uMslLCvIxAZwrxFKQW5WaWoMq/YhTnYFQS5n0LMoUnM68EbvcroLOYgM7 6eVwY5KySRISUVAOj2rW5D+OT3hRu6YnXSnQIUHJ5++HrjIxsvl8q61/LzNixdFGSfNpRSQG9 nYuWanja9Xw6fGKx/ySnmak3Kjdw7/phm7Wr7qaaj8GZK7dPPv/Pskj71B/fTT/ff1Vdam9oy b3jmNuXrZPDpoj98P+tGJK8JjFFP2imSMy+ovYvDonfjzytettbpMRSnJFoqMVcVJwIABHy4b nKAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-27.messagelabs.com!1511461939!113294630!1 X-Originating-IP: [209.85.128.196] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24990 invoked from network); 23 Nov 2017 18:32:19 -0000 Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by server-7.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:19 -0000 Received: by mail-wr0-f196.google.com with SMTP id a63so18316668wrc.12 for ; Thu, 23 Nov 2017 10:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Ykuugv1wRnCMhjTW6Y4HYWwWVvbSm5l2UqY4jm75HE=; b=c3tGbLUjyz/6g6aqwmYIbyLPtK0eZ50rSh9aDtZKhmAoT1IidhlX9yhutPgC1H/Fv3 FKIWp9+qeYVy2yOSuVvsu/T3FiwyQU51/J5CfhFiFlwnPUcGvJMSa+rvjWYAMAGL8X+t 58Hkyyg1WVLPE6Am310y8xEgtU8mcnszlU3mQ= 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:in-reply-to :references; bh=6Ykuugv1wRnCMhjTW6Y4HYWwWVvbSm5l2UqY4jm75HE=; b=cr4kwGRmHYs3OIGb8ZJUGIrheNGsQv9g7nBPWZyaeoKowU7fAf18gYEkoJveETKTJU +ilSwof7YD5abM1Se0MMZFs5SsggjJhkqB6kwgLVNLf9gmvHsAOJ/NG1rt5bPApjWtUe k7T0y6mVZvCSLemLJ0/RbNTufBba55K7Px0qiThg/jduG46gNzuWDGtFt1giGrYs01SR 9UC8kzxZtyjHX/a1B8Lm+VC3OZhym81oiX88rtff5z4gULjcm+Wt1Ol7GcltFXaqLF9a SSDozjw5pDPMUNchBrDcKtl6Qj/VDzC/Xo/t303y95jhqyDTWUm+2lKgB6AQ2CHfgcBu bd1g== X-Gm-Message-State: AJaThX7W+ProPNdS79S5XPUqsd298riQ7ne34dJpHp5Ys1Q1jgtf1AlT 1KMBowhnepQaU+dy7mQ5KB55U+E8zec= X-Received: by 10.223.139.67 with SMTP id v3mr22616174wra.70.1511461939269; Thu, 23 Nov 2017 10:32:19 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:18 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:31:58 +0000 Message-Id: <20171123183210.12045-5-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 04/16] xen/arm: Extend copy_to_guest to support zeroing guest VA and use it X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function copy_to_guest can easily be extended to support zeroing guest VA. To avoid using a new bit, it is considered that a NULL buffer (i.e buf == NULL) means the guest memory will be zeroed. Lastly, reimplement raw_clear_guest using copy_to_guest. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/guestcopy.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 1ffa717ca6..3aaa80859e 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -29,7 +29,16 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, p = __map_domain_page(page); p += offset; if ( flags & COPY_to_guest ) - memcpy(p, buf, size); + { + /* + * buf will be NULL when the caller request to zero the + * guest memory. + */ + if ( buf ) + memcpy(p, buf, size); + else + memset(p, 0, size); + } else memcpy(buf, p, size); @@ -65,35 +74,7 @@ unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned long raw_clear_guest(void *to, unsigned len) { - /* XXX needs to handle faults */ - unsigned offset = (vaddr_t)to & ~PAGE_MASK; - - while ( len ) - { - void *p; - unsigned size = min(len, (unsigned)PAGE_SIZE - offset); - struct page_info *page; - - page = get_page_from_gva(current, (vaddr_t) to, GV2M_WRITE); - if ( page == NULL ) - return len; - - p = __map_domain_page(page); - p += offset; - memset(p, 0x00, size); - - unmap_domain_page(p - offset); - put_page(page); - len -= size; - to += size; - /* - * After the first iteration, guest virtual address is correctly - * aligned to PAGE_SIZE. - */ - offset = 0; - } - - return 0; + return copy_guest(NULL, (unsigned long)to, len, COPY_to_guest); } unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len) From patchwork Thu Nov 23 18:31:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119538 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173126edl; Thu, 23 Nov 2017 10:34:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMb67hXYouiiDEklvmAkxEAfE3eU86bi7peod6glCt5pz06MUWRaBN4F6BnRRkLetV+T8m3A X-Received: by 10.36.139.198 with SMTP id g189mr12851147ite.13.1511462062640; Thu, 23 Nov 2017 10:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462062; cv=none; d=google.com; s=arc-20160816; b=IQ1ABwEhm+EyBrs6gU+SXlk22i8Fr6MUCOaAXZzKE1By5TLdwirg6gs8RSXEQNqsER FvBfwwU+AmtxyQXkIHPpBuzNJNoPWmOWUzbV6JHinycLBdh/7ycgWBPhrg2cxZZTy1Fq b2tD3hRYmnxAvYlR/B0yCmkthwD83cyYcRt+EMjOXoaCfFpNZLFR4fxnp48h8cgLE0VM guQ3D4EeGMWBaw6TTZUer4K8V4ZWK5v4QmXECMMyxmHueCEc//Z9fIh+O1GJriy2F5a7 6WwDaQ2fTsHzTkW7yJHuHCNuj2GLavG4bxFJWJy5c9GAn+yupV0wVVDQHzNTshE1YAWX 5yUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=knG8ZbBzRIlGjKwYUA7rK/qavOQ6YozwK4c7o8R3GJA=; b=jIPoM8X3NjIVDycRRDEEEhz0wa8S3FDaKmZkK1MZebM+8n01BreKD7OIoTf3E+1DHg F6Adt4aTBoI7nrSwFL0TthXvJ27hwmgdNhmk89wXygiSgImjG3UmVjXiAJV9wu4Cpvqi YMAvmovRnGKJcFlMZXX2i3i77RBtMCfB6Zz9m77+x1dx+e381capzjPS6Kil5UkUN7gn 4yn6bWq5fYfpxM0dHS8VypubgNaH1xgsyETx+PRs9BxIVAv8e8aERq619U6O4G9xX2AK P/87Sr1IdzOqJm7k+VqSg/b4NrC7LbUkk7BvuFWAKLjVXDy4fBc46MOcSdl52SktNv6V XyNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VcOE5Ol6; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i62si16051154ioe.220.2017.11.23.10.34.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VcOE5Ol6; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIR-0005Cf-8W; Thu, 23 Nov 2017 18:32:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIP-00059i-IM for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:21 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 82/CD-27709-534171A5; Thu, 23 Nov 2017 18:32:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVyMbThsK6JiHi UwZLpahZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aLXueCH0IVvd2nGBsYZ/B1MXJxCAlMYpRY eHgxO4jDIjCPWeLovbNsII6EQD+rxPn3V1i7GDmBnDyJM53TgKo4gOw0ib/v9SDCFRIfdrWxg oSFBNQk1ryJghjaxySx/8RyFpA4m4COxLoZtSDlIgLSEtc+X2YEsZkF4iUeT73OBmILC0RJrP 3xjgmknEVAVeLHuhIQk1fARuL/CkuIRfISu9ougt3CKWArcfTAB2aIpTYSnz8rTmAUXMDIsIp Rozi1qCy1SNfITC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzDMGIBgB+OZBYGH GCU5mJREeWV+iUUJ8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCVFBaPEhIsSk1PrUjLzAEGPExag oNHSYR3uxBQmre4IDG3ODMdInWK0Z7jwp1Lf5g4Duy5BSSfzXzdwMwx7WprE7MQS15+XqqUOO 9mkDYBkLaM0jy4obAIvcQoKyXMywh0phBPQWpRbmYJqvwrRnEORiVh3rcgU3gy80rgdr8COos J6Kyfx4VBzipJREhJNTB2X582U27yH6W6SbVN8z1De/X4u8UDz0pdsZIzb1nQ82X1pcorL92Y brvvPsb5v7zgh82HD8Gv9HMjJio+3hBk4eO6q1NK+5RumUj9hMkTz2XufmGsfH1rzYWI6z+V1 R3KP9+PUF7PUznzVf9s7v9L/eMlvQofXK26mf4p9GSuSEAOz4pFGxcosRRnJBpqMRcVJwIAcq tfQMsCAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1511461940!117542624!1 X-Originating-IP: [209.85.128.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17397 invoked from network); 23 Nov 2017 18:32:20 -0000 Received: from mail-wr0-f195.google.com (HELO mail-wr0-f195.google.com) (209.85.128.195) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:20 -0000 Received: by mail-wr0-f195.google.com with SMTP id w95so18372085wrc.2 for ; Thu, 23 Nov 2017 10:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FhFa2k4whtsema3mWHC6VkNUk+YCIUASBkprXRHjFCA=; b=VcOE5Ol6BeP67KdMREeRrrk7lsW/mFnQF8IOmPeHYcvxNUYM7ThbwVqipaVsSpSvx9 CeBt9YKQoGCFcFJhDXud2gzMfB2x1WxROo+PY2V830XcpGr1SayGeAAWhT4p1TUjT+CJ I6Q97bRx2RJJCf+CrafMoH6AH91YAEha7BYZM= 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:in-reply-to :references; bh=FhFa2k4whtsema3mWHC6VkNUk+YCIUASBkprXRHjFCA=; b=t3UH3lcnbuSAFijDU07JzPOrwnJXGly+c+JI0pl4w24NCFAh8uY/0ERsPdN4MTUyVw AxZ4wIoZqb4DhZ7ynZn5YI+dvGbhCBkaJmoWijFHQZQDRaw7uS98XByxd37MRvQpM0Lm WilVThG9k87Zq1SODTOGBxaVtXhOEKNR0X29laPxJuzh9gFpzMVQRwnti1UHkNoL7xNe +q8Eu517ud4r2qv3hEVe0P31dhAke+IJqcs5kIvGrOWToza9DjkpFOx/2EsXBX/aR5up PwgpL2f/hYidFDGkd82zq2V/ZkB+3rZD5PO1Pt8sAGebnrFkn0VApgKi7XAt7uZWNbQS /ouA== X-Gm-Message-State: AJaThX6O/ve30ghzzsItyhxFOaHGB/2M6Wdlcq+Gu8oqLJ1tCgxmayOP 3+JM117unWTQd1nLn/VPeLmyVOi9k8w= X-Received: by 10.223.182.7 with SMTP id f7mr12208437wre.71.1511461940074; Thu, 23 Nov 2017 10:32:20 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:19 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:31:59 +0000 Message-Id: <20171123183210.12045-6-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 05/16] xen/arm: guest_copy: Extend the prototype to pass the vCPU X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently, guest_copy assumes the copy will only be done for the current vCPU. A follow-up patch will require to use a different vCPU. So extend the prototype to pass the vCPU. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/guestcopy.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 3aaa80859e..487f5ab82d 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -10,7 +10,7 @@ #define COPY_to_guest (1U << 1) static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, - unsigned int flags) + struct vcpu *v, unsigned int flags) { /* XXX needs to handle faults */ unsigned offset = addr & ~PAGE_MASK; @@ -21,7 +21,7 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned size = min(len, (unsigned)PAGE_SIZE - offset); struct page_info *page; - page = get_page_from_gva(current, addr, + page = get_page_from_gva(v, addr, (flags & COPY_to_guest) ? GV2M_WRITE : GV2M_READ); if ( page == NULL ) return len; @@ -62,24 +62,25 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) { - return copy_guest((void *)from, (unsigned long)to, len, COPY_to_guest); + return copy_guest((void *)from, (unsigned long)to, len, + current, COPY_to_guest); } unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned len) { return copy_guest((void *)from, (unsigned long)to, len, - COPY_to_guest | COPY_flush_dcache); + current, COPY_to_guest | COPY_flush_dcache); } unsigned long raw_clear_guest(void *to, unsigned len) { - return copy_guest(NULL, (unsigned long)to, len, COPY_to_guest); + return copy_guest(NULL, (unsigned long)to, len, current, COPY_to_guest); } unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len) { - return copy_guest(to, (unsigned long)from, len, COPY_from_guest); + return copy_guest(to, (unsigned long)from, len, current, COPY_from_guest); } /* From patchwork Thu Nov 23 18:32:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119537 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173048edl; Thu, 23 Nov 2017 10:34:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMbpKKBv7/mkU/LZi6Hm0Db8miyomUH4Wr4ftTZF0u28o5l4WU1U10CpotyX1ERYbcaJsfEl X-Received: by 10.107.6.81 with SMTP id 78mr28180299iog.204.1511462058548; Thu, 23 Nov 2017 10:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462058; cv=none; d=google.com; s=arc-20160816; b=POJTNLXBh2XgAjEDwMp0UGfLTh7u6HY1+HlXXPnHzKM9m10YMesYqIStBwR29dC2nd H8Ida4zES3ow1nyqTn+U+JdKjBRE+o78oWaRJaPGXncQrlsxmOaf36zeXgIqwkVMJCV3 /yyWD6uah9qx5/oTBYolMHGEr0d1nhcXp642oZII61T+qHg7smrXRDgz0BUfkNe2nSNT FkiSua4Oq2T2DBqbBssj5euT590Gee2WliQ3Oh1avO2+DeY3v8P1s5sTEo0C9z5uZCla E1eMbrUZ1u8QHv3s2WAyfkVCou7YwUivEz9kx3jcBVCrmwlxWi+Wt4GvcAaX+XDZZTOM vORw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=uVSxMaT4MupCfzfA7UCFQxE799q9MjPSvEpxktaITSE=; b=kRXRZKXZUNzJA2mIUzUVFVXicoxELGi0A+rCQYvxCNcj6QXbHEFG97/2HmHEPWESe1 z4oA9V++elvWcX+CQE8VoQMyY1PMV0zrVYwgMYsR0nl7HHGHFfNcIgK3VBg8zWuebE83 ykyLltVvajMYZWhYmEqzGZ5dQ7i1Tq/SrF8DegrnXpHpVOp68+gZc0h1eOHF/6Wvbplg Cg8sQQjcZ6nqPTZExbYAbCwfnjOtMRN4MQfO00ZOH5OuSYQNlg+O5seIEIciowxwh+aO 6ej/YfvD4Cu+hrjWd3zUPx5cuIXlN4YTUIIdKLoq1wpcKEE14o8TzqfdWmis3v3Q4MEF +ALg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V+6Ou5gj; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v86si13338879iov.15.2017.11.23.10.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V+6Ou5gj; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIS-0005E4-GV; Thu, 23 Nov 2017 18:32:24 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIQ-0005BD-TM for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:22 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id DA/38-16045-634171A5; Thu, 23 Nov 2017 18:32:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsXiVRvkqGsqIh5 l0DtVw2LJx8UsDoweR3f/ZgpgjGLNzEvKr0hgzZhwdy1jwQWNihfHv7E3MB6T7WLk4hASmMQo Mbn9ACuIwyIwj1li2vKJbF2MnBwSAv2sEv9XCUHYeRLtPedZIew0iUNXNjF1MXIA2RUSnfdTQ UwhATWJNW+iIGb2MUk8Wj6VGSTOJqAjsW5GLUiniIC0xLXPlxlBbGaBeInHU6+DbRIWyJf4+6 ofbDqLgKrEyQ+t7CA2r4CNRHfbDhaIrfISu9ougtVwCthKHD3wgRlirY3E58+KExgFFzAyrGL UKE4tKkst0jU000sqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAw1BiDYwXh/Y8Ah RkkOJiVRXplfYlFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHhvColHCQkWpaanVqRl5gCDHiYtw cGjJMK7HSTNW1yQmFucmQ6ROsVoybFvz60/TBzPZr5uYOaYdrW1iVmIJS8/L1VKnNdTGKhBAK QhozQPbhwsMi8xykoJ8zICHSjEU5BalJtZgir/ilGcg1FJmPctyFqezLwSuK2vgA5iAjro53F hkINKEhFSUg2MIsEVxj9DOT+fncSUGLiA6ZfwXc0Zsy6Y1BVwmG12FNVcIMzAP/ugwtflISF6 M+sfCt8+fT7WPbTf4BzH5N//f1QwHr0SzTnTQ+K5aX9DVsRPjjqb+KWSFQpzPqjN0RJ5oXL70 aUFU07WHDDnkW7dwD9/V8eZCRl/lG8kh9+NUp1jlfox40ukEktxRqKhFnNRcSIAFn7Q7scCAA A= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-9.tower-21.messagelabs.com!1511461941!83248014!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40148 invoked from network); 23 Nov 2017 18:32:21 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-9.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:21 -0000 Received: by mail-wm0-f65.google.com with SMTP id g130so18043590wme.0 for ; Thu, 23 Nov 2017 10:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uN9SPlsMnyA58zYTd8x8DOAsv2jQYD12n8QFkobcRKs=; b=V+6Ou5gjcEkBRA6jDKdeQkeoC8KZ26NB3Vc31xx6BGR4OjvqZL7iT8EEE4SInRQhRA 7cs/QfXXG5mup99C9SH8bgeCRQ0Xv6C5NjeupNifMNWXa0jyFJyjnRbsj+ES5zDyK4kb ICKQ9+90GUVpTxODHGfhKxxCIX6X3ejBAG2I4= 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:in-reply-to :references; bh=uN9SPlsMnyA58zYTd8x8DOAsv2jQYD12n8QFkobcRKs=; b=bzx/F/sWNYNe+hPHcjlOHANVergsAmN4riEWiMdt9ZgcQO7076i20naEG+EfBTLTnq n+XZiv9i4tUDX35JGOujO99TN2qHCgV69hsJ61zxHbV/BYiri6jz0GaWkccKxuOc4P1H Ofpyv8J7aYlRQIgmNkr3dXLJheRgb1rqYFA8omPkGBiW9U90rYVjbC0esWxUKUR4Lz5P eI4D5Qap/L5eVC0OIcpHGg6Iy4RWDrWPSoBeRd3q/H0rVQcKiTGtDmwENuozTk8CnCh1 lmVAmcOjkB6K01fvDM8iJGTulDsS3x4hxwoNvcudnJnx+V0oW+x2QNc8g3ProuCJHXru pKlw== X-Gm-Message-State: AJaThX7LOkEo9cavejxRfQXSLZoNvIlZlStCEI8LWO3UXqoSCE7Nec2M yvSKQWgUqUVUaqWigZcNJTLdDjFr4bQ= X-Received: by 10.28.168.88 with SMTP id r85mr8624231wme.63.1511461940994; Thu, 23 Nov 2017 10:32:20 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:20 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:00 +0000 Message-Id: <20171123183210.12045-7-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 06/16] xen/arm: Extend copy_to_guest to support copying from/to guest physical address X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The only differences between copy_to_guest and access_guest_memory_by_ipa are: - The latter does not support copying data crossing page boundary - The former is copying from/to guest VA whilst the latter from guest PA copy_to_guest can easily be extended to support copying from/to guest physical address. For that a new bit is used to tell whether linear address or ipa is been used. Lastly access_guest_memory_by_ipa is reimplemented using copy_to_guest. This also has the benefits to extend the use of it, it is now possible to copy data crossing page boundary. Signed-off-by: Julien Grall --- xen/arch/arm/guestcopy.c | 86 ++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 487f5ab82d..be53bee559 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -8,6 +8,31 @@ #define COPY_flush_dcache (1U << 0) #define COPY_from_guest (0U << 1) #define COPY_to_guest (1U << 1) +#define COPY_ipa (0U << 2) +#define COPY_linear (1U << 2) + +static struct page_info *translate_get_page(struct vcpu *v, paddr_t addr, + bool linear, bool write) +{ + p2m_type_t p2mt; + struct page_info *page; + + if ( linear ) + return get_page_from_gva(v, addr, write ? GV2M_WRITE : GV2M_READ); + + page = get_page_from_gfn(v->domain, paddr_to_pfn(addr), &p2mt, P2M_ALLOC); + + if ( !page ) + return NULL; + + if ( !p2m_is_ram(p2mt) ) + { + put_page(page); + return NULL; + } + + return page; +} static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, struct vcpu *v, unsigned int flags) @@ -21,8 +46,8 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned size = min(len, (unsigned)PAGE_SIZE - offset); struct page_info *page; - page = get_page_from_gva(v, addr, - (flags & COPY_to_guest) ? GV2M_WRITE : GV2M_READ); + page = translate_get_page(v, addr, flags & COPY_linear, + flags & COPY_to_guest); if ( page == NULL ) return len; @@ -63,73 +88,40 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) { return copy_guest((void *)from, (unsigned long)to, len, - current, COPY_to_guest); + current, COPY_to_guest | COPY_linear); } unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned len) { return copy_guest((void *)from, (unsigned long)to, len, - current, COPY_to_guest | COPY_flush_dcache); + current, COPY_to_guest | COPY_flush_dcache | COPY_linear); } unsigned long raw_clear_guest(void *to, unsigned len) { - return copy_guest(NULL, (unsigned long)to, len, current, COPY_to_guest); + return copy_guest(NULL, (unsigned long)to, len, current, + COPY_to_guest | COPY_linear); } unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len) { - return copy_guest(to, (unsigned long)from, len, current, COPY_from_guest); + return copy_guest(to, (unsigned long)from, len, current, + COPY_from_guest | COPY_linear); } -/* - * Temporarily map one physical guest page and copy data to or from it. - * The data to be copied cannot cross a page boundary. - */ int access_guest_memory_by_ipa(struct domain *d, paddr_t gpa, void *buf, uint32_t size, bool is_write) { - struct page_info *page; - uint64_t offset = gpa & ~PAGE_MASK; /* Offset within the mapped page */ - p2m_type_t p2mt; - void *p; - - /* Do not cross a page boundary. */ - if ( size > (PAGE_SIZE - offset) ) - { - printk(XENLOG_G_ERR "d%d: guestcopy: memory access crosses page boundary.\n", - d->domain_id); - return -EINVAL; - } - - page = get_page_from_gfn(d, paddr_to_pfn(gpa), &p2mt, P2M_ALLOC); - if ( !page ) - { - printk(XENLOG_G_ERR "d%d: guestcopy: failed to get table entry.\n", - d->domain_id); - return -EINVAL; - } - - if ( !p2m_is_ram(p2mt) ) - { - put_page(page); - printk(XENLOG_G_ERR "d%d: guestcopy: guest memory should be RAM.\n", - d->domain_id); - return -EINVAL; - } + unsigned long left; + int flags = COPY_ipa; - p = __map_domain_page(page); + flags |= is_write ? COPY_to_guest : COPY_from_guest; - if ( is_write ) - memcpy(p + offset, buf, size); - else - memcpy(buf, p + offset, size); + /* P2M is shared between all vCPUs, so the vcpu used does not matter. */ + left = copy_guest(buf, gpa, size, d->vcpu[0], flags); - unmap_domain_page(p); - put_page(page); - - return 0; + return (!left) ? 0 : -EINVAL; } /* From patchwork Thu Nov 23 18:32:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119530 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172916edl; Thu, 23 Nov 2017 10:34:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMYcF7ZM9irCy/MOHr6a+yKlOt1CsygZpGOjUcChy8VsG9SWYWuklMNgUyNhx2Y0UY/r0h3S X-Received: by 10.36.120.135 with SMTP id p129mr12625546itc.87.1511462050272; Thu, 23 Nov 2017 10:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462050; cv=none; d=google.com; s=arc-20160816; b=YTsJji2Fz5dWT7co+/WeM8v0j1a1ktHp9H26zvIHI+Wbayhm2Kf2Ldv3soMD3tRMo3 w/qd2CQLHUsGDOW79E6+HRwt0fiwjk1LkgIORqiObeRjbhp8O6k8qOTMBnKIJShbKVMZ 9wBbmAFZFxpZVr0CibjByXouEnW2xy7Bgb5bVfy3yhbs8wT9dpenXMkqAOUljiKwJw+h Y+zKoSTdG00yagEG6d0FpYL0J4KCO426BnDc2D+a5zDFKJXeRR87+EPnvPyoyK5wkGeN uFeLWWlCBOXKMMK5m7Ib+OmZ1M0HbwhvZwU6eCpWKzjdX1B0tGetmovbikqGRBhIRkhd TayA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=UbB/1+UYoyINc4hngC1h+fX3asi2q+zDVEyMnN4CwQE=; b=qEwgQs0PVAnedRnNChfxE9BntjNJEbw0O4+gignzF+sQjhck53MENIHbQnp4+OLot9 88bz/aGrhsPTYX6mQwuTvNZ2wt8nFYxDEugc2YOICSe3zh48xl3c0wuXLp8JniQ2lWK2 QUHHoRvW5qR146X6rBUdYxxS0I/VEcWsnzt5T1WeUz83AFg8X3nwAz5/gpqCOGalG1fp 5rrkxxgr7O+1GGXDBqRIOx8yjl8aSeBVcnfX6OvZb3oFtLzqhH34jpyLebBKl33Q4bSm mkqgNXGxBlsZw0vpG1r2Xh5xh6U4Upaj68+AG2rK6UzcVVY1wzWpG8DsAtweNl1RVFjI MQxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LSO5tKDn; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f32si15821931iod.248.2017.11.23.10.34.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LSO5tKDn; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIS-0005Ea-NN; Thu, 23 Nov 2017 18:32:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIR-0005CO-JV for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:23 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id EC/6E-20254-634171A5; Thu, 23 Nov 2017 18:32:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsXiVRvkomsmIh5 l0PVVymLJx8UsDoweR3f/ZgpgjGLNzEvKr0hgzTixaA5zwUeBip7dC9kbGP9xdzFycQgJTGSU ONXXzAzisAjMY5bYcLuVHcSREOhnlVj6+R5TFyMnkJMn0XrtLiuEnSbx42gXUAcHkF0hMWETI 4gpJKAmseZNFMTQPiaJJVMOsoDE2QR0JNbNqAXpFBGQlrj2+TIjiM0sEC/xeOp1NhBbWCBI4u SqL2ATWQRUJW40ZIKEeQVsJH48WcAIsVReYlfbRbADOAVsJY4e+MAMsdVG4vNnxQmMggsYGVY xahSnFpWlFukamuklFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgSGGgMQ7GCc+j7u EKMkB5OSKK/ML7EoIb6k/JTKjMTijPii0pzU4kOMMhwcShK8fcLiUUKCRanpqRVpmTnAoIdJS 3DwKInwLgFJ8xYXJOYWZ6ZDpE4xWnLs23PrDxPHs5mvG5g5pl1tbWIWYsnLz0uVEuf1BGkQAG nIKM2DGweLzEuMslLCvIxABwrxFKQW5WaWoMq/YhTnYFQS5l0MMoUnM68EbusroIOYgA76eVw Y5KCSRISUVAMjQzQHcwjbRpVJd+SjOyMFl2YvXsH8fctRbjPP7lUuP7PNTuv/Nw0W3/LhZoew h1Mo1zWFTXfU7WaKbLxwftnrbfHxUfvmBtQs5Nuyf9UvK2thVb/IQ0tuW6esXBpgYypo9291X dDtTUtOnf663PJapNoSFnnOn7terph+L2FfgzGP6a6bP45fUGIpzkg01GIuKk4EANEEUpfHAg AA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-9.tower-206.messagelabs.com!1511461942!108664476!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54156 invoked from network); 23 Nov 2017 18:32:22 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-9.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:22 -0000 Received: by mail-wm0-f68.google.com with SMTP id x63so18278293wmf.4 for ; Thu, 23 Nov 2017 10:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KWIl5fS94/S1+VaJSGlsGIK86ijHSyRIXcY0HJcjrXM=; b=LSO5tKDnDY+9Bu66oxKQEKNb1RcfM4ErcWeuxL1gigbIAVeNGOxNi4J3FhhyZTMQxC 3SClesQnj8RjotpmLRmnGRvImQu4UoTRdJzlDIUTEfgCZcClKTyUlHw8XQIX4SGiwe+K iFiOjnhLbVcgt7YyML2LXnWS3aRSq3N7NHN6U= 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:in-reply-to :references; bh=KWIl5fS94/S1+VaJSGlsGIK86ijHSyRIXcY0HJcjrXM=; b=it6+QZxhJ7ppA5IkxNWENSFft06jfnFEKxX1st58BwNpKCvw56E0XQ/OKUyALJfu5g tugMggXhMCBhzkXlE7+FHo4bjGp1mCK7DXvxuGNlY8jzhKmVnlPaah5i0F0yKjCIgpLj 8MRvUXSjrvw4+PhrxfFdNGv1gxc4bE1HTPsQCBTY+FvUCvQawhuFy0b+d2wkSyp0gUYM 7fnLKkDnr8Ko/797fd0bMdwqzRARn7rsHvjS5Odn7UGZiMCxwIpZKuc62xU+4lvGd/tK 5CMvlRMYu4gFx6KVoThD9zMCk3h+s+QyNVLG+i0w8a1uzTuU7GEULVceh+c/FpTTFb7t RFGg== X-Gm-Message-State: AJaThX5vituXSBf+2NOPc37ndeHLjJy/L2fR/pqUGc4AIOL88w/GUltO iIqNZiI3IYyJySPAl+/6kNSS41rucGA= X-Received: by 10.28.14.195 with SMTP id 186mr7612245wmo.56.1511461941829; Thu, 23 Nov 2017 10:32:21 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:21 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:01 +0000 Message-Id: <20171123183210.12045-8-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 07/16] xen/arm: Introduce copy_to_guest_phys_flush_dcache X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This new function will be used in a follow-up patch to copy data to the guest using the IPA (aka guest physical address) and then clean the cache. Signed-off-by: Julien Grall --- xen/arch/arm/guestcopy.c | 10 ++++++++++ xen/include/asm-arm/guest_access.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index be53bee559..7958663970 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -110,6 +110,16 @@ unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned le COPY_from_guest | COPY_linear); } +unsigned long copy_to_guest_phys_flush_dcache(struct domain *d, + paddr_t gpa, + void *buf, + unsigned int len) +{ + /* P2M is shared between all vCPUs, so the vCPU used does not matter. */ + return copy_guest(buf, gpa, len, d->vcpu[0], + COPY_to_guest | COPY_ipa | COPY_flush_dcache); +} + int access_guest_memory_by_ipa(struct domain *d, paddr_t gpa, void *buf, uint32_t size, bool is_write) { diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h index 6796801cfe..224d2a033b 100644 --- a/xen/include/asm-arm/guest_access.h +++ b/xen/include/asm-arm/guest_access.h @@ -11,6 +11,12 @@ unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned long raw_copy_from_guest(void *to, const void *from, unsigned len); unsigned long raw_clear_guest(void *to, unsigned len); +/* Copy data to guest physical address, then clean the region. */ +unsigned long copy_to_guest_phys_flush_dcache(struct domain *d, + paddr_t phys, + void *buf, + unsigned int len); + int access_guest_memory_by_ipa(struct domain *d, paddr_t ipa, void *buf, uint32_t size, bool is_write); From patchwork Thu Nov 23 18:32:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119529 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172901edl; Thu, 23 Nov 2017 10:34:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMazWxqwhnGtAleZIcxhq78XIHUwa7bhnCB+Y4qYJJDXfHM4NhT1Mraiu64lugP50Sp31ANh X-Received: by 10.36.146.215 with SMTP id l206mr10347084itd.25.1511462049562; Thu, 23 Nov 2017 10:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462049; cv=none; d=google.com; s=arc-20160816; b=c57BBDl3ugHCGYPtaR1O2x8WEVMiMWLGM5mJ8rYLWnoH1aLeDoOml/E2CC/oZoQ/A6 a1SDCaVkkItT6BfmF4+Hl8AkuFub8srFD5mBTsgDoFZ0wfZJNo8MAuH0SlFXdLWulVhd VMKbqvppD+57F7L9DibPQ1JcTmfCzvh/z2f4vWY84aOktHIUQH90SVCBbVNvx/uR0hxx kwipKYAi6gqf1uIbWpB1N/cNjPparbG6h0yqYM2FpP43olqYAuFuIgtBmi856/Pn9sqw AuuApmCGIjAG3yERdhdMPyzehm/W9wjwXqPafWjSMzhXpCMiHUDDT9HxG87rC9o7Snau hiUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=2oFy9zK/eQpvJNZM+3ZWL8Mhy+K+NoiLOmaMbmBBlKw=; b=psUCxFNUeOhI6IAszl9yYeot+Co5KLdgEg8ZYEV6Shgakur/K29l4ip5DuHMUfhPzY cDLNMtjO6gTHHftX+k12H3YOEJeuqnGGqR0DSeIx15VqFTfiruGrNMR3urOIQjQQmVLg AsDwmeO90HNXhUiZM1W1jBV1JJz3AJbYxvzEyE7iRzp1LIvtFUUhwYlZQ4WRpYBRUngP hQgWmICuVHpT7bwVfq3YSxwHuLCyBUESElVMvcpkVJpqZYvBT+W5zhufgUc69RpnGTtm DnTvk2F5apZMkTc9tXUhmXwQUf7FQtxv6NLjnPHqitH6hXCoyN4iXCzc8VTqqe74/jpW Ytug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ELxIXEu0; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i8si13377362iob.204.2017.11.23.10.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ELxIXEu0; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIU-0005Go-1f; Thu, 23 Nov 2017 18:32:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIR-00059i-Vr for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:24 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id AD/CD-27709-734171A5; Thu, 23 Nov 2017 18:32:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsXiVRvkrGsuIh5 lMGESn8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFywTrmgj7JivctL9kbGJcJdzFycggJTGSU WNXv3cXIxcEiMI9ZYlHrSRYQR0Kgn1Vi5uvHbCBVEgJ5EhuvPGSEsNMkdt/oZIWwKyU2XdjE1 MXIATRJTWLNmyiQXiGBPiaJnV8OsYPE2QR0JNbNqAUpFxGQlrj2+TLYGGaBeInHU6+DjRcWyJ RYeOQKO4jNIqAqsWb2ATCbV8BG4vWG2VAnyEvsarsItpZTwFbi6IEPzBBrbSQ+f1acwCi4gJF hFaN6cWpRWWqRrpleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgqDEAwQ7GeSf8 DzFKcjApifLK/BKLEuJLyk+pzEgszogvKs1JLT7EKMPBoSTBe1NIPEpIsCg1PbUiLTMHGPQwa QkOHiUR3u0gad7igsTc4sx0iNQpRkuOfXtu/WHieDbzdQMzx7SrrU3MQix5+XmpUuK8m0EaBE AaMkrz4MbBIvMSo6yUMC8j0IFCPAWpRbmZJajyrxjFORiVhHnThIGm8GTmlcBtfQV0EBPQQT+ PC4McVJKIkJJqYEyN+CO7T3fmAQP5P1xtsj8MJMqdZ34VmBeaLelY276rW8t3z5Ho74uMtu54 YXPiq+GOBSenKD0/J+jxS1uQ6+eazTxs+50uTXM8eet6f3PAkX0z92f8+Kv2Q+y4B4P4p/XyC x/mJsj0LwldMMM75fn5vvbIY0qTf4Vfbj92TKLAcd2PAKkNV74rsRRnJBpqMRcVJwIAQrImlM cCAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1511461943!116436948!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31200 invoked from network); 23 Nov 2017 18:32:23 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:23 -0000 Received: by mail-wm0-f67.google.com with SMTP id 128so18309940wmo.3 for ; Thu, 23 Nov 2017 10:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EkEWKS3KD6BOY8J1/VZIM+kubCBL2zD7NpsdCjfJLpE=; b=ELxIXEu0JrVsPdbzMm1dphBgKPkBrH/XXkMp6KdPiBEhQsODptSo6bnBHuvrCLJ2KW W0srKZmhtM2tN5P+aQL6mTPoT1ygqeVN0i6JhBJQDdqOY4JRV9jKHjd1t3UndTqhNFej gfHaf0MbjfnrBDZKHTtXByXKmHDgZxlhr8wOQ= 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:in-reply-to :references; bh=EkEWKS3KD6BOY8J1/VZIM+kubCBL2zD7NpsdCjfJLpE=; b=IXtW0Cdqzlajr8CaksT5hZQKH/9Ofq58435iLuY5X776SKwN//s6Dhr8tGsEDJZ2Nb 4io+2WTGI7Qke6rkNyk9lewbqWdsKh1yQT8bS0Ymv+FR9Aq+uNwO7uCw7AaWS8sudwYe uT5uGdxrIHZyLAbgqmiBx8E5xlLyozFdq3htiuoEn6/nGRGcAG1baHhxni873k34PkLt T1I/rMO213FO2Wl/PCplW1BlHsueIj+s7B9nCWk2czzdaIxirr0rFVUoTOtWIVssjc05 FBUBhZ5LSlPGfeZAYpJr5sz3hPPK6fPY/+/mRBjViOwLwN0dqeZRiX7WIp7VbSEq7azH q+Eg== X-Gm-Message-State: AJaThX4mIcrCoZklr/C6TrL5grkiSiUXEQPgodKvQ9LWeVh5OmRuI04T x30fmfs06xDOA1AIzC9fFf0pVtocBoc= X-Received: by 10.28.229.19 with SMTP id c19mr6967478wmh.156.1511461942681; Thu, 23 Nov 2017 10:32:22 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:22 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:02 +0000 Message-Id: <20171123183210.12045-9-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 08/16] xen/arm: kernel: Rework kernel_zimage_load to use the generic copy helper X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function kernel_zimage is dealing with IPA but uses gvirt_to_maddr to do the translation. This is currently working fine because the stage-1 MMU is disabled. Furthermore, the function is implementing its own copy to guest resulting in code duplication and making more difficult to update the logic in page-tables (such support for Populate On Demand). The new copy_to_guest_phys_flush_dcache could be used here by temporarily mapping the full kernel in the virtual space. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/kernel.c | 33 ++++++++++++--------------------- xen/arch/arm/kernel.h | 2 ++ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c74f4dd69d..3f87bf2051 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2133,6 +2133,7 @@ int construct_dom0(struct domain *d) d->max_pages = ~0U; kinfo.unassigned_mem = dom0_mem; + kinfo.d = d; rc = kernel_probe(&kinfo); if ( rc < 0 ) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index a6c6413712..2fb0b9684d 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -15,6 +15,8 @@ #include #include +#include + #include "kernel.h" #define UIMAGE_MAGIC 0x27051956 @@ -157,7 +159,8 @@ static void kernel_zimage_load(struct kernel_info *info) paddr_t load_addr = kernel_zimage_place(info); paddr_t paddr = info->zimage.kernel_addr; paddr_t len = info->zimage.len; - unsigned long offs; + void *kernel; + int rc; info->entry = load_addr; @@ -165,29 +168,17 @@ static void kernel_zimage_load(struct kernel_info *info) printk("Loading zImage from %"PRIpaddr" to %"PRIpaddr"-%"PRIpaddr"\n", paddr, load_addr, load_addr + len); - for ( offs = 0; offs < len; ) - { - uint64_t par; - paddr_t s, l, ma = 0; - void *dst; - - s = offs & ~PAGE_MASK; - l = min(PAGE_SIZE - s, len); - - par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); - if ( par ) - { - panic("Unable to map translate guest address"); - return; - } - dst = map_domain_page(maddr_to_mfn(ma)); + kernel = ioremap_wc(paddr, len); + if ( !kernel ) + panic("Unable to map the hwdom kernel"); - copy_from_paddr(dst + s, paddr + offs, l); + rc = copy_to_guest_phys_flush_dcache(info->d, load_addr, + kernel, len); + if ( rc != 0 ) + panic("Unable to copy the kernel in the hwdom memory"); - unmap_domain_page(dst); - offs += l; - } + iounmap(kernel); } /* diff --git a/xen/arch/arm/kernel.h b/xen/arch/arm/kernel.h index c1b07d4f7b..6d695097b5 100644 --- a/xen/arch/arm/kernel.h +++ b/xen/arch/arm/kernel.h @@ -15,6 +15,8 @@ struct kernel_info { enum domain_type type; #endif + struct domain *d; + void *fdt; /* flat device tree */ paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */ struct meminfo mem; From patchwork Thu Nov 23 18:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119533 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172965edl; Thu, 23 Nov 2017 10:34:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMZvn04LrEjKKi9xljTM1E1lpFGdja1eDsI4gO+t72x7EPHV+Kt55tmHTun/TgLIcHwnBkVQ X-Received: by 10.36.70.195 with SMTP id j186mr12717002itb.32.1511462052785; Thu, 23 Nov 2017 10:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462052; cv=none; d=google.com; s=arc-20160816; b=eDE7SEnsUFdPwLFlZ9ccTx6vtvXahFVv5/0kwL98iv5EJwrJvOlx+HT+ZMatBBlg89 dMSJwaUrbqoDJLjyBAZmmTPMgZ0sdtyyXJlChDkpKqvX5aIkMNafscCDI1UnUE5UQLml N99AoPTCgBJU6mpMRTt5sfV59zssmY2RQHDZqTHh1RzCFqozIRW6XD4lqfUswrykJSCs kOJ+Qnofb5iN6p/r94ikBqnYjOuIlaNZam8LUwkEMKdd9oplI2T/ue6B8eGMakmrs5cG 2n5NOd9TPz/0jipAUvwvlLsgVa8CYEbQeAlvW4BJiE54oOkrFPpmJhNJrUG/pfadRCSE PyFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=/mJxN7HeKZnY1JDbX8ZqU9MTrUj4kFy1Oo42aVP3JSs=; b=1H8w1rMRxg/yHeCTflevPiaOk0h1UiKXtldGqq+qnojnmZqVuCHjFz4Jb1peIIuol+ 7ZDpwEy1asbrZY7QgkjdFyzG1zWzspKxPJ5AT3x9gA2m2jr2YGUND16j92a6IUgyTOrO MFfIRYHPYr6GewUskieIVswjYVYZlsId1hp9yEtcBQpfc5IJril5/SOUES9/x9LA0Ajq TKjTxtZG4Fgw/jODEt+WVOoGe2TnD5/JDPNZpUsb4M6pizHMuKEJ57y+lSbhq5KLIgjG FhsyHSCvarKiiQUWj/flZicgHSybZ05LnzbQ/p9zFRMstJFrq91VGvGd1BIuB2Av87EQ nRMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gVG8ij+B; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n66si6601853ith.136.2017.11.23.10.34.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gVG8ij+B; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIU-0005HQ-9l; Thu, 23 Nov 2017 18:32:26 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIT-0005Fm-Ki for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:25 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 88/7D-20334-834171A5; Thu, 23 Nov 2017 18:32:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMbThoK6FiHi UQccedoslHxezODB6HN39mymAMYo1My8pvyKBNePEoZWMBa1CFRfvv2ZrYDzM28XIxSEkMJlR 4n5/BwuIwyIwj1libV8DE4gjIdDPKvF7whbGLkYOICdPoudQaBcjJ5CZJtH7Yyo7hF0tcf/YY yaQEiEBNYk1b6IghvYxSfx49IcNJM4moCOxbkYtSLmIgLTEtc+XGUFsZoF4icdTr4OVCAtkSE y9GQISZhFQlVjZMYcNxOYVsJVYfnEuC8QmeYldbRdZQWxOoPjRAx+YIbbaSHz+rDiBUXABI8M qRo3i1KKy1CJdIyO9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYzAUKtnYGDcwbin 3e8QoyQHk5Ior8wvsSghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErySwuJRQoJFqempFWmZOcCgh 0lLcPAoifCmgaR5iwsSc4sz0yFSpxjtOS7cufSHiePAnltA8tnM1w3MHNOutjYxC7Hk5eelSo nzeoK0CYC0ZZTmwQ2FReklRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8b4WApvBk5pXA7X4 FdBYT0Fk/jwuDnFWSiJCSamA8yDXvDIOIX2BLLQ8j+4IthXYR7+wYZ+/8djKgc8vf4huntvZ9 u76Qd6bcNMdNCkWJpo1eht2TIqxfVEzemROUb8tZYvt+1+Ybu2fkp5Tnefx6esLHUP1w4Kq0i ae+3lotmWUv6B/HcXKH+8KoNn1eHf2XaQYvK7myA+96tvHbLlw6j9lxxRIlluKMREMt5qLiRA BflyXNzQIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1511461943!93057739!1 X-Originating-IP: [209.85.128.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10017 invoked from network); 23 Nov 2017 18:32:24 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:24 -0000 Received: by mail-wr0-f193.google.com with SMTP id l22so18298029wrc.11 for ; Thu, 23 Nov 2017 10:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ah/TxKQ67+b+C7qrGiEEvL3vmN2Qqd+Tgaa6bNltHpQ=; b=gVG8ij+BA5EVgsPjSFz1Ivg3N+rbyv3HCrIFvdLzCBBwO/3c2/XPHr/0wMx8wGipSM /5a3a63tU8fgx6w46kIzyOreLZHZ/tmCa98JhGMWjsifVP+EsR1AUA9p4htiRCpQXIcJ htR5idJTgdywH/XsMOmvH6yaSzXNP0I4v2YcM= 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:in-reply-to :references; bh=ah/TxKQ67+b+C7qrGiEEvL3vmN2Qqd+Tgaa6bNltHpQ=; b=JW4QQDUXZVhRXV4txMCLLf2Ndbti9B/Lcj8ysfg0xQWfZqJvuXAjo14yyiQF4YWtjW rbdWPtIdJivUsJGlOYmW1nSLZyM0UD5/q230Immuo2Ra3A4tAbw9W38gfUqlEY7k5jfb r1UMPEiYZTOpAKz3vn335rTNtbjXVNrDPGoemfxOLpxaNI6JeV0777xtvm7dRuh0DIEd kcEnDfgMAm6VimOtcWs5H5UiDLpxWcfQyHym4KU3TlRr2wKkunKuqr6F1rd8Mlt2vL5p aKmBCbApiiUlZ/WKKPNF+rQXkqZB6H1PNFUo/X5lgI49YB0KjPzsxKKOCf0JgF5QTEyX 8FEA== X-Gm-Message-State: AJaThX78ks7lwCM8Cv0pPGMbeAqad0A7U2DT6vyTa+fK9E3rtOUWFp6X d91MOAZYYHF81kT4z1fDP7AvpOCjKfk= X-Received: by 10.223.160.61 with SMTP id k58mr14048662wrk.252.1511461943550; Thu, 23 Nov 2017 10:32:23 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:23 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:03 +0000 Message-Id: <20171123183210.12045-10-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 09/16] xen/arm: domain_build: Rework initrd_load to use the generic copy helper X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function initrd_load is dealing with IPA but uses gvirt_to_maddr to do the translation. This is currently working fine because the stage-1 MMU is disabled. Furthermore, the function is implementing its own copy to guest resulting in code duplication and making more difficult to update the logic in page-tables (such support for Populate On Demand). The new copy_to_guest_phys_flush_dcache could be used here by temporarily mapping the full initrd in the virtual space. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3f87bf2051..42c2e16ef6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1966,11 +1966,11 @@ static void initrd_load(struct kernel_info *kinfo) const struct bootmodule *mod = kinfo->initrd_bootmodule; paddr_t load_addr = kinfo->initrd_paddr; paddr_t paddr, len; - unsigned long offs; int node; int res; __be32 val[2]; __be32 *cellp; + void __iomem *initrd; if ( !mod || !mod->size ) return; @@ -2000,29 +2000,14 @@ static void initrd_load(struct kernel_info *kinfo) if ( res ) panic("Cannot fix up \"linux,initrd-end\" property"); - for ( offs = 0; offs < len; ) - { - uint64_t par; - paddr_t s, l, ma = 0; - void *dst; - - s = offs & ~PAGE_MASK; - l = min(PAGE_SIZE - s, len); - - par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); - if ( par ) - { - panic("Unable to translate guest address"); - return; - } - - dst = map_domain_page(maddr_to_mfn(ma)); + initrd = ioremap_wc(paddr, len); + if ( !initrd ) + panic("Unable to map the hwdom initrd"); - copy_from_paddr(dst + s, paddr + offs, l); - - unmap_domain_page(dst); - offs += l; - } + res = copy_to_guest_phys_flush_dcache(kinfo->d, load_addr, + initrd, len); + if ( res != 0 ) + panic("Unable to copy the initrd in the hwdom memory"); } static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo) From patchwork Thu Nov 23 18:32:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119532 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172963edl; Thu, 23 Nov 2017 10:34:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMamzrO0tF1J6nnnBV2Wg8tEgTuASsJAp8M5O8UM9+USM2O9Lxq46IsrMVkoL3umkgwTmCfe X-Received: by 10.36.227.3 with SMTP id d3mr12911618ith.47.1511462052623; Thu, 23 Nov 2017 10:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462052; cv=none; d=google.com; s=arc-20160816; b=QIuJf6u7P8PHHp4QEt8XjZnOMXIVOApwB2x83GUgNEoiqO4z0+qqbSYIv6JEeMAfkw OefAtxKJPdJPqyIwTxM5yGQuf6FiGu+JVeeJBwVGofmb7T9We99OqGGhjQkkHubIQCKz vevqSRHNGHffaF8QAHr7wmoz3DPLCTxhEaDrnu5aLPmWhYpbbm0LhdBL/eUAm9pPNtEw CQcObQxBA4a0m4BLkdtfm55r57ESb9iB9T+jAp6FrX9BBBIdpzalttQK0MNfdyaV1wQ/ +k4p8yqbJ5w+nLBipCt728LhyrYwKx9bOGsx+2xNGVMZIsRYFEtwSbFFdmIzMnsWaVo9 6Xww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=m/ZFIvDX9Hya/jLmFQ4dF3UXmz2bmmdENiLX/VtVcPk=; b=L79wxsjd4WY293bs3y5nimQQNR56GfAKOJK+I3dbqIufBIfoJJdiry1KWkcWqQl8L/ byw3zrmoHVXQq55RhJjh+zsRzukzdxIFF4OPaHsfFFZ5kTQ+rQ7jlJRCUviFmrpb8W89 haacL9Zk/5Aa+Ieem7mQ6iU2zsWliuDl7RBbV5LQXndRq8LjHd9iwcMfYO2m84JMt1hy ++r1feb2P7KZzdi2poZ3WH7KAdipv3I814/4FJ3bJbTx702LY6plSwUbxpzdKEahXK1t YWxlbLh6ekt131NCGLhpFTYjfoAZzskxc/LmKPwpYEX1RfWwWd3eN4F6xtZ9A2LXL2Uw i0sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=d706IPKq; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l74si4102846ioe.133.2017.11.23.10.34.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=d706IPKq; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIV-0005JA-It; Thu, 23 Nov 2017 18:32:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIU-0005GM-3s for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:26 +0000 Received: from [85.158.143.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id 63/3D-26583-934171A5; Thu, 23 Nov 2017 18:32:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsXiVRvkpGshIh5 l0Ntsa7Hk42IWB0aPo7t/MwUwRrFm5iXlVySwZvTemsRYcIe74t6dU8wNjN2cXYycHEICExkl 5qwS72Lk4mARmMcssenMUUYQR0Kgn1XiyZr/LCBVEgJ5Ev93bwOyOYDsNImZ3yMgzAqJq8+NQ UwhATWJNW+iQDqFBPqYJJ7cX8MIEmcT0JFYN6MWZIiIgLTEtc+XGUFsZoF4icdTr7OBlAgDDX x5PwkkzCKgKvFpz3WwnbwCthK7X12D2i8vsavtIiuIzQkUP3rgAzPEVhuJz58VJzAKLmBkWMW oXpxaVJZapGuol1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGGQMQLCDcedzp0OM khxMSqK8Mr/EooT4kvJTKjMSizPii0pzUosPMcpwcChJ8EoKi0cJCRalpqdWpGXmAMMdJi3Bw aMkwrtdCCjNW1yQmFucmQ6ROsVoz/Fj0pU/TBz79twCks9mvm5g5ph2tbWJWYglLz8vVUqcdz NImwBIW0ZpHtxQWHxeYpSVEuZlBDpTiKcgtSg3swRV/hWjOAejkjDvW5ApPJl5JXC7XwGdxQR 01s/jwiBnlSQipKQaGF2/OUonle4KX91ZJ7JTxOuJ4iHVcuWMvL7a7fI7FigFOid/W8RieIH1 7JxE/hXH5s0xtb5bGmFa5Pz9wIKry2alB6r5f7E1PusdqFpY+cPRzji16NHM7h07SzYtcY2Pu nZgd+zlVxkGNTP1HF45bqsovbopsfztFVepwr4g4b2z2eIbHzt8VGIpzkg01GIuKk4EADSz1o TKAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1511461944!76751757!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20885 invoked from network); 23 Nov 2017 18:32:24 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-10.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:24 -0000 Received: by mail-wm0-f66.google.com with SMTP id u83so18573030wmb.5 for ; Thu, 23 Nov 2017 10:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L4ecF+4jUObl7GroU/XAZ8xAnCtevI1gOyTw981gxFY=; b=d706IPKqhEMib+yJ/8OtQA6CgV+c5DihWhqT411qXOwSbU4eA29fbTIYkDEM+OF+9g SGNVF7eLUbczYt0DYlHHx/XQ2KBwhrROWnp/3P90X2mGxx0Au89Ry88fNGJ7hkpnBaiD NZGymKa32Oh3dqto+7fRGPGMzKuLQFBRSa1lU= 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:in-reply-to :references; bh=L4ecF+4jUObl7GroU/XAZ8xAnCtevI1gOyTw981gxFY=; b=TWGSGA3t6IP3/Xnz9vs0xZAwq99TV1UCg8lytCQa3n4DN9v1k0eAy/GIZCcaeZUiv8 Xb6/ywx1ZSsl/iLbgxN3MAYQLNKLUNDSKw4yoP7hlZkavabItvYLIi3pzmMk1lmoiv25 ytJprGgTzFL+3vgMY/Dxtw5KlZw1LyZCKG+RBdc9rXMea4UW8OY+PPVlfw9oa3bN0Tuh GSfHgMPewzTss0MzuLbcwZUp2gUzBy5oK3c2OP03q0bS2iRheWJLYjFaxhMDvgO0ns1r B16Mazy14oIe+NH0NmjZxLjy/YinbBGB53OwWDZqafbzHKCwTX6o+0/G2y1eds2FGO7J arkQ== X-Gm-Message-State: AJaThX4VZeXum4BJBGUe+jXh/XiBLwF4RuVV+8XPAUrKyo6GSwQNhBgx wow8lXVPXJ9elU37eTK/rJgn7we6Dd0= X-Received: by 10.28.232.129 with SMTP id f1mr7330805wmi.32.1511461944463; Thu, 23 Nov 2017 10:32:24 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:23 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:04 +0000 Message-Id: <20171123183210.12045-11-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 10/16] xen/arm: domain_build: Use copy_to_guest_phys_flush_dcache in dtb_load X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function dtb_load is dealing with IPA but uses gvirt_to_maddr to do the translation. This is currently working fine because the stage-1 MMU is disabled. Rather than relying on such assumption, use the new copy_to_guest_phys_flush_dcache. This also result to a slightly more comprehensible code. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 42c2e16ef6..9245753a6b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1948,14 +1948,15 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) #endif static void dtb_load(struct kernel_info *kinfo) { - void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr; unsigned long left; printk("Loading dom0 DTB to 0x%"PRIpaddr"-0x%"PRIpaddr"\n", kinfo->dtb_paddr, kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt)); - left = raw_copy_to_guest_flush_dcache(dtb_virt, kinfo->fdt, - fdt_totalsize(kinfo->fdt)); + left = copy_to_guest_phys_flush_dcache(kinfo->d, kinfo->dtb_paddr, + kinfo->fdt, + fdt_totalsize(kinfo->fdt)); + if ( left != 0 ) panic("Unable to copy the DTB to dom0 memory (left = %lu bytes)", left); xfree(kinfo->fdt); From patchwork Thu Nov 23 18:32:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119539 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173164edl; Thu, 23 Nov 2017 10:34:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMYibn2KQ1aHqnvvh/lyRZ4mfEUXqpqAevFIoXvJwvfneWd+pB8pWBfujIwpYRtVupDBXXZL X-Received: by 10.36.8.136 with SMTP id 130mr13064565itc.18.1511462064754; Thu, 23 Nov 2017 10:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462064; cv=none; d=google.com; s=arc-20160816; b=U3gkrRBLMNAqSem45C+IB0xpTi6tfmg86ibf2totyekN6CHGhVWffnAZeUGIGNuM9g jZCn61p9QZpU1qOKvjrCuhnASTTgY0qRCoYuv3v6xNK14sgbNOM69kxuhfrWLOb3kSVV dQRsl0HrMZvo3UAcbtArX3+Vqy582yta+IbMS29bxzU9twxXQhSLqWcPk7PGWvWe2RBF Yy4yRt5OnOfpmAqgwuYVLhgTt+dAN7PccM4RJSLTcq41UOZs0dD+1LOfq1S0E7+5eH1F 9YIGcOkbyZWh+s6eWl3FtXSDuqLeYVsjJAsg3aSqx8/lsWnXaeC2q8szxrxRtIfQFYYt XZQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Duiw9XlLNa4Nuw0iVkR5oGC2mCz2u79bNwxpSONgTy4=; b=UlyZfJuyNyON1MuCBt8xaTw6aIQSjQFyOm5cQl6xi8360f7YVuJEz0WIwUcsmrGNJz sI+WmmJsW9pzd/TkO+nlT7KlV2aTekJW4GKQNt/RfnAHoxvpQVxnXKUBdbGtQGxGRza3 9yGfdX3LDgCYFcC3Vtec32uHdCG5PbGkc/3x2W+ezX2Rd0VhXijWjDfgaQBplWcMP9wj tS5yk8wSKZdD2w/wV+AypLqmm2tr7/E1Fev4+6LqKWCxUK+I95T2rPQdArSjYUXUj/PN V/AKCPV76qlpyhas+t3iv8vFZF4OeHU5GUvydw+nnDjYsNFQ9FuUb2dUU0rHWPU1nUH8 k0KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Q0Zqd82e; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m82si6689419itg.119.2017.11.23.10.34.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Q0Zqd82e; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIW-0005Kj-Qy; Thu, 23 Nov 2017 18:32:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIV-0005IQ-9J for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:27 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id F4/79-16578-A34171A5; Thu, 23 Nov 2017 18:32:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXiVRvkomspIh5 lsPavpcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvHp4F7mgsWSFRNPzmNsYLwg3MXIySEkMJFR Yu0nrS5GLg4WgXnMEgc39rCDJCQE+lklHj+Vh7DzJA7s2sIMYadJrFi4ggnCLpfovTmLsYuRA 2iQmsSaN1Egc4QE+pgk3sxvZQOJswnoSKybUQtSLiIgLXHt82VGEJtZIF7i8dTrbCC2sECkxK xdZ8BsFgFViTOLL4CdwCtgK3H46h2otfISu9ousoLYnEDxowc+MEOstZH4/FlxAqPgAkaGVYz qxalFZalFupZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBgcYABDsY724KOMQo ycGkJMor80ssSogvKT+lMiOxOCO+qDQntfgQowwHh5IEr6+weJSQYFFqempFWmYOMORh0hIcP EoivGkgad7igsTc4sx0iNQpRkuOfXtu/WHieDbzdQMzx7SrrU3MQix5+XmpUuK8niANAiANGa V5cONgcXmJUVZKmJcR6EAhnoLUotzMElT5V4ziHIxKwhBreTLzSuC2vgI6iAnooJ/HhUEOKkl ESEk1MEq+2CAQkJ9adpQh+1RLS2/4bR2BQsPzbv/Zaw2WbXS+WTJB/Wtl9f2Xp6W2XSyyeJtT XnX/uoSa4J+I56vN7V/2VXdMeHYma21R6u3QADW3DU/u7Np87NZD+ds3kjkdV16t/p2Sq5jpp LbOa94rwfVX31ZEfOyKqP305qN608XyiOZ7c784uSmxFGckGmoxFxUnAgCR/JytxgIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1511461945!117588512!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11775 invoked from network); 23 Nov 2017 18:32:25 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:25 -0000 Received: by mail-wm0-f68.google.com with SMTP id u83so18573112wmb.5 for ; Thu, 23 Nov 2017 10:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VOhnq4hr2RAsU8IGX5a9VAFVlDtgFmfUZHGYfGQWn08=; b=Q0Zqd82eIwZa6mrYMqtl7OvEEA/nbP9htbtn72cluIdLNk9++XbH558K8eYXJ5cUxx +0Ri99EgwgDFwcD0MkQnruazFM5TyPzhi95MlsMBMYI3vd5GMGgySfh9Jr0nMn9iuILl j5fFOS0aymhN1q4cjw5zMQa7hpe9AjhKFIREI= 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:in-reply-to :references; bh=VOhnq4hr2RAsU8IGX5a9VAFVlDtgFmfUZHGYfGQWn08=; b=CuB6IdotkuWL17UXM2QcJqoVwnoL0h42tgs1+eAnLbUwcNLUged/3Z5w0h72Lck7VY idssGdm2Sqnqs1rakk3Gp0ZPwvRMmubpOfH3s5oGp0q9HiiM26J4Yh08C7r564ti5fx7 iDxk1Ucp4BdV/+TNpbN6y1fGKwBReyFjjOpHD2JxclkFql1pfonocPqZiPVSMKRBRsvf X7POaH0ZvKW8VVNQ/B5MUIstnzAjr//BuBSJ+7BF75za+ZU4Eo9RBZL/Sevb39UHoWUa qtKNMPpQ/XpCVsR8rsX+a+ooABqcMmBTKgbYYQtBUAyEkR4tsPK/IcvccmP7nOaI3/8K JMBQ== X-Gm-Message-State: AJaThX5Yp0u81zGGuV2bJIs+paWNo3CHZ4SzIIxEZXr6ihSSZ8PcC97c HQNZLwnMrY6bF7JqvIapm/NdOT9Udag= X-Received: by 10.28.69.136 with SMTP id l8mr7715044wmi.19.1511461945386; Thu, 23 Nov 2017 10:32:25 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:24 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:05 +0000 Message-Id: <20171123183210.12045-12-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 11/16] xen/arm: p2m: Rename p2m_flush_tlb and p2m_flush_tlb_sync X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Rename p2m_flush_tlb and p2m_flush_tlb_sync to respectively p2m_tlb_flush and p2m_force_tlb_flush_sync. At first glance, inverting 'flush' and 'tlb' might seem pointless but would be helpful in the future in order to get more easily some code ported from x86 P2M or even to shared with. For p2m_flush_tlb_sync, the 'force' was added because the TLBs are flush unconditionally. A follow-up patch will add an helper to flush TLBs only in certain cases. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 417609ede2..d466a5bc43 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -52,7 +52,7 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; -static void p2m_flush_tlb(struct p2m_domain *p2m); +static void p2m_tlb_flush(struct p2m_domain *p2m); /* Unlock the flush and do a P2M TLB flush if necessary */ void p2m_write_unlock(struct p2m_domain *p2m) @@ -65,7 +65,7 @@ void p2m_write_unlock(struct p2m_domain *p2m) * to avoid someone else modify the P2M before the TLB * invalidation has completed. */ - p2m_flush_tlb(p2m); + p2m_tlb_flush(p2m); } write_unlock(&p2m->lock); @@ -138,7 +138,7 @@ void p2m_restore_state(struct vcpu *n) *last_vcpu_ran = n->vcpu_id; } -static void p2m_flush_tlb(struct p2m_domain *p2m) +static void p2m_tlb_flush(struct p2m_domain *p2m) { unsigned long flags = 0; uint64_t ovttbr; @@ -170,11 +170,11 @@ static void p2m_flush_tlb(struct p2m_domain *p2m) * * Must be called with the p2m lock held. */ -static void p2m_flush_tlb_sync(struct p2m_domain *p2m) +static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) { ASSERT(p2m_is_write_locked(p2m)); - p2m_flush_tlb(p2m); + p2m_tlb_flush(p2m); p2m->need_flush = false; } @@ -675,7 +675,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, * flush? */ if ( p2m->need_flush ) - p2m_flush_tlb_sync(p2m); + p2m_force_tlb_flush_sync(p2m); mfn = _mfn(entry.p2m.base); ASSERT(mfn_valid(mfn)); @@ -864,7 +864,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * For more details see (D4.7.1 in ARM DDI 0487A.j). */ p2m_remove_pte(entry, p2m->clean_pte); - p2m_flush_tlb_sync(p2m); + p2m_force_tlb_flush_sync(p2m); p2m_write_pte(entry, split_pte, p2m->clean_pte); @@ -940,7 +940,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, { if ( likely(!p2m->mem_access_enabled) || P2M_CLEAR_PERM(pte) != P2M_CLEAR_PERM(orig_pte) ) - p2m_flush_tlb_sync(p2m); + p2m_force_tlb_flush_sync(p2m); else p2m->need_flush = true; } @@ -1144,7 +1144,7 @@ static int p2m_alloc_table(struct domain *d) * Make sure that all TLBs corresponding to the new VMID are flushed * before using it */ - p2m_flush_tlb(p2m); + p2m_tlb_flush(p2m); return 0; } From patchwork Thu Nov 23 18:32:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119540 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173166edl; Thu, 23 Nov 2017 10:34:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMaX3BHQNuud560hMVfHf5UxBT4VGUCePo/XDHKmSME5rsqFmR4HK/dRb3W92NifdtY6OqzN X-Received: by 10.107.152.137 with SMTP id a131mr6058565ioe.168.1511462064817; Thu, 23 Nov 2017 10:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462064; cv=none; d=google.com; s=arc-20160816; b=NYvuWbHvp+HYSGv6UWqNVBHONawtPy/IY7lfVlP3xKH/O8po31Sz9IMctY3L3Ir8cs 6NJA6wW7qACvWrElmCGs9jxk5tAPKkfV2ldvi9w3zMRHhNWd+3TVm6iSj2UhLxcnMMPp 38yAvfDODAHUiFFzO37U4YyeHJcHoepeIvtQ2K0cjIOGvsi1w9TSU14TfsqP67X2e7Mx WkJ9CvOBU4E/ZT/+I/J9beFmtU3b8etQ86dxvpl9ms+ZLfzkLvhs0I+ssA+v9CDGUtOX Uq0OSPt0cNgm3K8HVrzioCqRlSkOUlEQGnbcCPfS8vnpq3TiaSO2p80w+dImw56DT8pF KA4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Ta7MMkvR11k6A4cA7ntwCNg1hN1FtK8DARNo1HPnUIM=; b=jUxwO3EHR1l7nojCGZsz6WD0YLzUV+m+3Q4JCJOw+YeYFunuYtnXDuiNP3SkKR4smq 4XNXYtbhovDLHW4BsG1bvke7jkFkKmfeJKrT34m2ntfCPIqDIGXJ2Odm+nE6JfTik8pi hBPSfJtBhrVoQy6vDe7MEr1kWuTWubrU+5snZXzDZTjRCViAQp/AhqdvNQOnYIVbxits vOrG91JOJOKlOFSWfFu/Ygxr21p3GmNiBaZS8qHxYur9MIvYJoTwyjEisIuJhVHTM0tM BGAekogF1peopOBbmmJEEq5liDjuC1TSwZcWXJ9VPrZEra5QWSfMKrKAJ+ifcpTXyeog D4Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AxQ9K4FN; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 188si15488351ioy.340.2017.11.23.10.34.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AxQ9K4FN; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIX-0005LH-2K; Thu, 23 Nov 2017 18:32:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIV-0005GM-Iv for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:27 +0000 Received: from [193.109.254.147] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id E1/4D-26583-B34171A5; Thu, 23 Nov 2017 18:32:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMbThoK6ViHi UwZV5+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bbr9eMBftFKjauusXewLhMoIuRi0NIYBKj xNpff5hAHBaBecwSx76sZgRxJAT6WSV6ptwHynAAOXkSsy7pdzFyAplpEsc2drFC2NUS1+bOZ AUpERJQk1jzJgpiaB+TxKGVJ1hA4mwCOhLrZtSClIsISEtc+3yZEcRmFoiXeDz1OhuILSyQIN Gw6BTYSBYBVYnD7/ewg7TyCthK3PgoArFJXmJX20WwEk6g8NEDH5ghttpIfP6sOIFRcAEjwyp GjeLUorLUIl1DE72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMBQYwCCHYzXNwYc YpTkYFIS5ZX5JRYlxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXV1g8SkiwKDU9tSItMwcY9DBpC Q4eJRHeNJA0b3FBYm5xZjpE6hSjPceFO5f+MHEc2HMLSD6b+bqBmWPa1dYmZiGWvPy8VClxXk +QNgGQtozSPLihsCi9xCgrJczLCHSmEE9BalFuZgmq/CtGcQ5GJWHet0JAU3gy80rgdr8COos J6Kyfx4VBzipJREhJNTAGJlcGzI9ZMffr9PBN8VFd35oYI5uvlCXkG+bPSObefqe03bOsQnrK vJeM10q9nPPbza+ar2K7Vyr57MmvqdftXaIVkst8DrJWfC5IFntwv6/9s5dd1acp077naN0pf 6c4xZtpJg9PgdmjwvjF9vW2d3Zy31+6NcWIk838hjJf5MniCV42JUosxRmJhlrMRcWJANgxlI LNAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1511461946!86077051!1 X-Originating-IP: [209.85.128.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60502 invoked from network); 23 Nov 2017 18:32:26 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:26 -0000 Received: by mail-wr0-f193.google.com with SMTP id r2so11880555wra.13 for ; Thu, 23 Nov 2017 10:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OALbocxEW05El2yhHyd/LYeU+h70nklR+nhp/ggr13o=; b=AxQ9K4FNOZYQPeGsyxS56UHUuiIPCi1tfk15CXYjUEiXuNoBV6pwcCb0BgModVJtlE HTxrRwf9qq9vC3RUvchfQJPGszdJRDCajhcPZYZ4as+cCMwUEp6CKwAKszyumzzEGfDr JII+9epsL4adRFDw+vVHHHrXCo8la0GyakFWY= 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:in-reply-to :references; bh=OALbocxEW05El2yhHyd/LYeU+h70nklR+nhp/ggr13o=; b=nMRxzwtYi3J1D2YweYKOMqsAMJMiunE3OdOCurwmHOSXe+1cDA/bv2pSwsYdXw6xJJ RBL8QGGHDg1D27aH80vNfiZW6GTbyOrzu/drPLoDC3irAFVEoIFbnT6FG4rWZ0Ok2x8g 1niJ8tUa0EgTjA3ohKTeA5r3A1/ETMZVowP2bwejOQOPrRuqRPVe/QUA79Mj9bGAGapw qnVJ9/DxIjHp14Ycwr7zyTTTKxw0ljYBfyfAEkUaVxr8k+SEh2qfPY3tZQuci3aFhsik uj/OFuSSjIvTvJZZMPPlYLRR4ayeZJH//EkLM6+6pQ3v+lszoPeebj453W6Zcq6mYmxM ioXA== X-Gm-Message-State: AJaThX5BhChdzZ5XQR/jA0U9QWxTyjhkyuu66QArbzMTE23JAIfM0AVp HgpSSrKo8qctZ3qYqnGWJMTjS8SUY4A= X-Received: by 10.223.178.130 with SMTP id g2mr21122968wrd.129.1511461946181; Thu, 23 Nov 2017 10:32:26 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:25 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:06 +0000 Message-Id: <20171123183210.12045-13-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 12/16] xen/arm: p2m: Introduce p2m_tlb_flush_sync, export it and use it X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Multiple places in the code requires to flush the TLBs wonly when p2m->need_flush is set. Rather than open-coding it, introduce a new helper p2m_tlb_flush_sync to do it. Note that p2m_tlb_flush_sync is exported as it might be used by other part of Xen. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 27 +++++++++++++-------------- xen/include/asm-arm/p2m.h | 2 ++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index d466a5bc43..37498d8ff1 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -52,21 +52,15 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; -static void p2m_tlb_flush(struct p2m_domain *p2m); - /* Unlock the flush and do a P2M TLB flush if necessary */ void p2m_write_unlock(struct p2m_domain *p2m) { - if ( p2m->need_flush ) - { - p2m->need_flush = false; - /* - * The final flush is done with the P2M write lock taken to - * to avoid someone else modify the P2M before the TLB - * invalidation has completed. - */ - p2m_tlb_flush(p2m); - } + /* + * The final flush is done with the P2M write lock taken to avoid + * someone else modifying the P2M wbefore the TLB invalidation has + * completed. + */ + p2m_tlb_flush_sync(p2m); write_unlock(&p2m->lock); } @@ -178,6 +172,12 @@ static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) p2m->need_flush = false; } +void p2m_tlb_flush_sync(struct p2m_domain *p2m) +{ + if ( p2m->need_flush ) + p2m_force_tlb_flush_sync(p2m); +} + /* * Find and map the root page table. The caller is responsible for * unmapping the table. @@ -674,8 +674,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, * XXX: Should we defer the free of the page table to avoid the * flush? */ - if ( p2m->need_flush ) - p2m_force_tlb_flush_sync(p2m); + p2m_tlb_flush_sync(p2m); mfn = _mfn(entry.p2m.base); ASSERT(mfn_valid(mfn)); diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index faadcfe8fe..a0abc84ed8 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -204,6 +204,8 @@ static inline int p2m_is_write_locked(struct p2m_domain *p2m) return rw_is_write_locked(&p2m->lock); } +void p2m_tlb_flush_sync(struct p2m_domain *p2m); + /* Look up the MFN corresponding to a domain's GFN. */ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t); From patchwork Thu Nov 23 18:32:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119542 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173260edl; Thu, 23 Nov 2017 10:34:31 -0800 (PST) X-Google-Smtp-Source: AGs4zMYbWKDpwpwREWWPh5QcKPeskeRbNkKVWLJAulpjeFqyTYMqEpqb5FFQxkfTeQ8pywBdYuJN X-Received: by 10.36.111.194 with SMTP id x185mr12505292itb.54.1511462070971; Thu, 23 Nov 2017 10:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462070; cv=none; d=google.com; s=arc-20160816; b=TOJ7sxvclo/WTje4ql6qBAjU9OD5AqDwjmcQHuXMEvz1UpwLs0UHAPdkZHafCv57FB 00AF4HkFvMFTu2i8GHg7LhSYoWSlD3xcJ/P9JAfvNLSavOjcSs9GlBNapsiIsZKVKD2F p2LowbE/H4WBNnFuZJ+Ma8Hgdd0lbBdbMy1E3fr6kYxuEMslSaAv4H2N7XK3RlCiQjJl GMjYVZdtNdXBbPnlBtyObzc9+nPvOX6UlrjEv9rWYFQzWLMoQBEr+i6DGP8Blt2k/zEm uTkR3wuAclI29YQyUSJKwT8S6aiCEKqXDQG9UtkRtZo7os2qdBIJXfBnHino0P1PnCrx uisQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=A/Rau7nX0m5hgOOwTQu7L0XhgfogeVHLI8xFsAzRB1s=; b=xWrYeMaS+za8g1uidbLIYj+Cjse1z1ZXYqMQGqicUhkyZLxsp3ZP2cjVYdVFTGJeNp Ch7gN7U4/4t88pn/sUE4h000nNz40uHEPaFwmqQT58JvWbBuMR16rW4ttv3ITyeay6jV wutN+9z/irgy143k8CvZJyz4rSY5EXcJdU0W1zh6GqcuDeIrHuijvy+kDNYbBFVskn52 bhqWNytc9BUf4psqkEak8SUEmxWjc3Uzqst9xc7aDd9N63pk17g+8hVuiY7HQHyoDQ9F qnMj+kzAfWnI0fPG/xA1hybdQYVtomT4zTxCzzlzxIEaYNrEXhyQX/N407rJ0Z8m6CbT s3Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bS0XT+oo; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y93si15417811ioi.157.2017.11.23.10.34.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bS0XT+oo; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIX-0005MP-EP; Thu, 23 Nov 2017 18:32:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIW-0005KI-Rg for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:28 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id 5A/99-05156-C34171A5; Thu, 23 Nov 2017 18:32:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsXiVRvkrGstIh5 lsO6mksWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvHzyRG2gsf8Ff8P/GJpYLzD08XIxSEkMIlR 4kz/ZhYQh0VgHrPEt96NYI6EQD+rxMlX3exdjBxATp5E8824LkZOIDNN4mbDKSYIu0Li98r/r CAlQgJqEmveREEM7WOSeP/sJlicTUBHYt2MWpByEQFpiWufLzOC2MwC8RKPp15nA7GFBeIkLv /9DmazCKhKzN+7lR3E5hWwlThxZCo7xCp5iV1tF1lBbE6g+NEDH5gh1tpIfP6sOIFRcAEjwyp GjeLUorLUIl1DU72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMBgYwCCHYzflgUc YpTkYFIS5ZX5JRYlxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXUlg8SkiwKDU9tSItMwcY9jBpC Q4eJRHe7UJAad7igsTc4sx0iNQpRkuOfXtu/WHieDbzdQMzx7SrrU3MQix5+XmpUuK8m0EaBE AaMkrz4MbBYvMSo6yUMC8j0IFCPAWpRbmZJajyrxjFORiVhHnfgkzhycwrgdv6CuggJqCDfh4 XBjmoJBEhJdXAaLRpdufT2qZlu0VXrEuZ2tR+5Izn9cqpHXNc+CXWxRvkhkj4+qxw2ZWn7SWs 4cGU1Pro96w3rHzbXJWepE1bOPXi9xUWjh0aeVuWpLIx7uDx+/pTJml9zKdKrdK63nkv875yy B0sEZLW3JHwVUvk+EdlyzOfsvt+sO0I9D53Rkbk9lKDxa/llFiKMxINtZiLihMBWOB5h8gCAA A= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1511461947!108371538!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43345 invoked from network); 23 Nov 2017 18:32:27 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:27 -0000 Received: by mail-wm0-f67.google.com with SMTP id b189so18300972wmd.5 for ; Thu, 23 Nov 2017 10:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vt43YlirSpRxAzszWynNZEwmBlzw2ATzrU5DYNCb3Ps=; b=bS0XT+oowaobs7MqfzShdW0urD/ow5YvBXWimBn5CA7H9sfXjJLp7r/BVu/8FOYi2Y HYsgjoN4uvk++hH+Tov+dHrejzE+Or8T3tOHOCWKnmIUd2Cs/wE9UxVw8vmQ1PL0CvkP HgyzsN+iqJSl3afqUqfbLAjecskJSPLGCusIU= 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:in-reply-to :references; bh=vt43YlirSpRxAzszWynNZEwmBlzw2ATzrU5DYNCb3Ps=; b=Kquc5y7LQ8kOMf1KcWTrbIxQMIMiuNwudt/JtJmzqSSemIowwVdJmdt1clZZNWYDCT FlqCLcpkhEgZOumxIoTjZqMXAdg6l5yxgMX/UvPkUEkKGUh/2x1JoYlbaZpBpX/Yug1Y u40wrmWwQzEgL0h+DkxdJ/i5dQZCjKqEj/Vcqp0PBRqvybw2N/9WgnVPnn0T69dh2mNk Kd097H0Hx2kVRA9EQ9Tj9Ya1Q+9gar3oHrKVOdvO71ByOLriC9rh51JfrGd8o6NyAR3E ZWg21JMVzHwvyj+udXbA3DQWSXWh6ajJrKdQIC9I5f3MVb/Y2TN1obGs9JXMMAyaqyyq oKLA== X-Gm-Message-State: AJaThX5yF2wSaJM/PnCkb8ZhdbDbbMfPZIi9Ckl3WVFs1lpKXrpFkohr nnapqsrbYM78wtBI1+1PqHB0ET+qc20= X-Received: by 10.28.156.67 with SMTP id f64mr7427972wme.42.1511461947022; Thu, 23 Nov 2017 10:32:27 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:26 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:07 +0000 Message-Id: <20171123183210.12045-14-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 13/16] xen/arm: p2m: Fold p2m_tlb_flush into p2m_force_tlb_flush_sync X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" p2m_tlb_flush is called in 2 places: p2m_alloc_table and p2m_force_tlb_flush_sync. p2m_alloc_table is called when the domain is initialized and could be replace by a call to p2m_force_tlb_flush_sync with the P2M write locked. This seems a bit pointless but would allow to have a single API for flushing and avoid misusage in the P2M code. So update p2m_alloc_table to use p2m_force_tlb_flush_sync and fold p2m_tlb_flush in p2m_force_tlb_flush_sync. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 37498d8ff1..5294113afe 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -132,11 +132,18 @@ void p2m_restore_state(struct vcpu *n) *last_vcpu_ran = n->vcpu_id; } -static void p2m_tlb_flush(struct p2m_domain *p2m) +/* + * Force a synchronous P2M TLB flush. + * + * Must be called with the p2m lock held. + */ +static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) { unsigned long flags = 0; uint64_t ovttbr; + ASSERT(p2m_is_write_locked(p2m)); + /* * ARM only provides an instruction to flush TLBs for the current * VMID. So switch to the VTTBR of a given P2M if different. @@ -157,18 +164,7 @@ static void p2m_tlb_flush(struct p2m_domain *p2m) isb(); local_irq_restore(flags); } -} - -/* - * Force a synchronous P2M TLB flush. - * - * Must be called with the p2m lock held. - */ -static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) -{ - ASSERT(p2m_is_write_locked(p2m)); - p2m_tlb_flush(p2m); p2m->need_flush = false; } @@ -1143,7 +1139,9 @@ static int p2m_alloc_table(struct domain *d) * Make sure that all TLBs corresponding to the new VMID are flushed * before using it */ - p2m_tlb_flush(p2m); + p2m_write_lock(p2m); + p2m_force_tlb_flush_sync(p2m); + p2m_write_unlock(p2m); return 0; } From patchwork Thu Nov 23 18:32:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119541 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173227edl; Thu, 23 Nov 2017 10:34:28 -0800 (PST) X-Google-Smtp-Source: AGs4zMY9WMbsO1TbVI62qjKEd6w13NJ5rl5s3wOYPLsfWvDasHfdfNMZy0pR3i6YiocQOxrgCGUG X-Received: by 10.36.6.142 with SMTP id 136mr12439444itv.121.1511462068772; Thu, 23 Nov 2017 10:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462068; cv=none; d=google.com; s=arc-20160816; b=aUQalmEoEbZ4YIqlz6ewv4vLB7A+mq3Fqo8Csc3yK9WTEHPz2bylS5/wLIpu3fS1Z/ 4BiOgnuScuHutk4Y8Ah3zER2neaxc+Y6DRLadomr5vPNmFWUVgZG+8HIXOeipTxqqdDX HML7jnEoT3kgoM3yHngZEH7xiyDQUNUJOvfzrVDs0Y2mVU2zyMo4/BtUoZTS4pv8+zxN mxT4pKD1QwEtIqTs2YS0SL2YRhA9uyDRLMFHG2bcepewYlEUSwDDilOIq0W8EltoDWop jM7GPRb9h9zPugNI3YuI2Ok1ijL3LSmH2xc5/e7IFA1krll1pQN0iSn70Eys2k0A2yQW qWkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=6LhMJKC/wcBToDppIdKP1iR8KY/UfLD1z560tWD8dYU=; b=AFNSWqObpoB14oV0kqSkVhi6gXp+gr/V5X0Fq16bKYWGBBBtUhdrU1f0v1utF3UfhA Mmbwv9JA4XwhN3DOtVnJSUxNPJbKkruUVVDIGHmHpy+ZoWRlspf0D4r0CiPCfJA2lhNC GcVxPgctFa3xMzThEcuK0R5AKP5LLmYhedc9zLhtRlLZZErFgXRT4wc6qRFtJKvlC1Ev k3dwjmXJ7fsiqaoAir64TgYKFFsX+EYYOuS0EGk7yJpBpz7X537ruuGjgkeINOOGqX5m nYyDqqQ/zV23FaTpjnaymlbF2M+ILoQM/o5Kf+F9bgkGS0ZsybB5zpUnvw0VLL4Ciu6w tMpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WjB3uVav; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m128si14679951ioa.343.2017.11.23.10.34.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WjB3uVav; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIY-0005On-NM; Thu, 23 Nov 2017 18:32:30 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIX-0005Ll-LF for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:29 +0000 Received: from [85.158.143.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-4.bemta-6.messagelabs.com id 65/B8-08078-D34171A5; Thu, 23 Nov 2017 18:32:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMbThsK6NiHi Uwe6lMhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8avm+dZC16LVExe/IypgXGXQBcjF4eQwARG iTf7Z7GAOCwC85glWt5fYQJxJAT6WSXaPy9j7WLkBHLyJB5M6WSDsNMkNl08yAJhV0uc+PKQv YuRA2iUmsSaN1EgYSGBPiaJ81srQcJsAjoS62bUgoRFBKQlrn2+zAhiMwvESzyeeh1sorBAqM S/HXMYQcpZBFQlNjyrBAnzCthKzOpfxgyxSF5iV9tFsGM4geJHD3xghlhqI/H5s+IERsEFjAy rGDWKU4vKUot0jQz0kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECQ40BCHYw/loW cIhRkoNJSZRX5pdYlBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3iQh8SghwaLU9NSKtMwcYNDDp CU4eJREeLeDpHmLCxJzizPTIVKnGO05Lty59IeJ48CeW0Dy2czXDcwc0662NjELseTl56VKif NuBmkTAGnLKM2DGwqL0kuMslLCvIxAZwrxFKQW5WaWoMq/YhTnYFQS5t0EMoUnM68EbvcroLO YgM76eVwY5KySRISUVAPj6v1rfvXMWP+05Nvlw1yVimLTCxc7LFc6u33lvaL6nI5o766y24se PNpqxpK3iz/nTFhUip7mrO3bcxRbn32Sf112zrzwkTFbzI9OCz7d6Q+3ya9eV1z5QaKx75IOt 3lT/RaBe+53vyfMyZxmkMu34/7+3MAv9is965Tm7V4ttpjpDJu/aqytEktxRqKhFnNRcSIAN9 NKhc0CAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-14.tower-21.messagelabs.com!1511461948!76719303!1 X-Originating-IP: [209.85.128.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35568 invoked from network); 23 Nov 2017 18:32:28 -0000 Received: from mail-wr0-f195.google.com (HELO mail-wr0-f195.google.com) (209.85.128.195) by server-14.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:28 -0000 Received: by mail-wr0-f195.google.com with SMTP id 55so2039884wrx.0 for ; Thu, 23 Nov 2017 10:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fSagf4D63ts2OU9nYBVJZgUUAL8mdkjoXuy9Ln/jkC8=; b=WjB3uVavVv8tmv9AfDds9b5mHqce9m/UPbihyyIx836jkYHRX9PY/cHSo+xkQ3VJh+ M4wW+1goVydgllBsRiXYMh2CVik54gyOxkH4fRgAsnQ8cW2x9xilch+4PIBBRfxZqgJU 1OT9FDF9/1JZ+ownI/wbpnwu184XpI0ttkwH4= 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:in-reply-to :references; bh=fSagf4D63ts2OU9nYBVJZgUUAL8mdkjoXuy9Ln/jkC8=; b=h04T5jqLEgLUjWUNqyaz+6KdEiMXkod2YIaJjuhmn9SSARwLtaKZQ5bJFqI62ttynN sHPnbVvRNDDeCWUNi4BR2+auF6kvWf7clA5A4XZ/q3X3IuuqrWootwDy7oRop7DutEQf HJc8viw0Zqbsh6T2iu4dcjfnWdx8Xb7kRoloiG+7jQ9oz6j8rNi1PNkdHzivX5BJbNpH h9NxnBD9NNV3f/RmDQ6Igqlf8hNv2J/yP8zga2BI0xvqA/dLcF68rjEUvt2UR2auUK4P DUrZB/fata0dOqkWMb+xZau8W/DpawcHrxmnBEBxdyCaRbnDJHiqQYLUFdKwEfy7dOUC CQmg== X-Gm-Message-State: AJaThX41ryefJw+hNRSkCekv2MEU6a1n46hll2kAeCNhcCsArjmryhMQ 9p/7hFD625kBpu6SdZN1QiXv/VHo+RM= X-Received: by 10.223.154.244 with SMTP id a107mr20957315wrc.8.1511461947898; Thu, 23 Nov 2017 10:32:27 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:27 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:08 +0000 Message-Id: <20171123183210.12045-15-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 14/16] xen/arm: traps: Remove the field gva from mmio_info_t X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" mmio_info_t is used to gather information in order do emulation a region. Guest virtual address is unlikely to be a useful information and not currently used. So remove the field gva from mmio_info_t and replace by a local variable. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/traps.c | 13 +++++++------ xen/include/asm-arm/mmio.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index f6f6de3691..e30dd9b7e2 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2001,6 +2001,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, { const struct hsr_dabt dabt = hsr.dabt; int rc; + vaddr_t gva; mmio_info_t info; uint8_t fsc = hsr.dabt.dfsc & ~FSC_LL_MASK; mfn_t mfn; @@ -2014,13 +2015,13 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, info.dabt = dabt; - info.gva = get_hfar(true /* is_data */); + gva = get_hfar(true /* is_data */); if ( hpfar_is_valid(dabt.s1ptw, fsc) ) - info.gpa = get_faulting_ipa(info.gva); + info.gpa = get_faulting_ipa(gva); else { - rc = gva_to_ipa(info.gva, &info.gpa, GV2M_READ); + rc = gva_to_ipa(gva, &info.gpa, GV2M_READ); /* * We may not be able to translate because someone is * playing with the Stage-2 page table of the domain. @@ -2041,7 +2042,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, .kind = dabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla }; - p2m_mem_access_check(info.gpa, info.gva, npfec); + p2m_mem_access_check(info.gpa, gva, npfec); /* * The only way to get here right now is because of mem_access, * thus reinjecting the exception to the guest is never required. @@ -2078,8 +2079,8 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, } gdprintk(XENLOG_DEBUG, "HSR=0x%x pc=%#"PRIregister" gva=%#"PRIvaddr - " gpa=%#"PRIpaddr"\n", hsr.bits, regs->pc, info.gva, info.gpa); - inject_dabt_exception(regs, info.gva, hsr.len); + " gpa=%#"PRIpaddr"\n", hsr.bits, regs->pc, gva, info.gpa); + inject_dabt_exception(regs, gva, hsr.len); } static void enter_hypervisor_head(struct cpu_user_regs *regs) diff --git a/xen/include/asm-arm/mmio.h b/xen/include/asm-arm/mmio.h index c620eed4cd..37e2b7a707 100644 --- a/xen/include/asm-arm/mmio.h +++ b/xen/include/asm-arm/mmio.h @@ -29,7 +29,6 @@ typedef struct { struct hsr_dabt dabt; - vaddr_t gva; paddr_t gpa; } mmio_info_t; From patchwork Thu Nov 23 18:32:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119527 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172711edl; Thu, 23 Nov 2017 10:33:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMYghF5A6EbE0NHtPxJlRVnP4Znj9OGosPusKQ6OqnvKAWHOZj13kbKRbobUu/DD3vd3o4Ci X-Received: by 10.107.22.71 with SMTP id 68mr20776340iow.150.1511462036321; Thu, 23 Nov 2017 10:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462036; cv=none; d=google.com; s=arc-20160816; b=H02UgaFJ5H6sG20NLrUhog9QthGktNV0QNAvI8chpOhVMmKeHp+4xXLuMo5RKhHv2E 6Y04cFxJ5yzPqgbD00EFrD7pwJpdRR/+gQNltl3IdusaKckZ+52h0aNAgYTFaLjZkvdT xMAJBeGwi0bkEvAl+XKWPiDF6KYsn/qoFy/fwinZlDeN5y5qv/HE0ap5i6Ezc5cthWcY SO7DpCiOunybIMDFQ7d7g5o/NHorVuqFmV9suhy1G3Xq2oTovXlV84WZKVgvTTAAN8uT v+JyKV7Q90TGJKqQVrYqZMbuXlyWVE3Vp+6JDONUs6t9ASkjEOyQx9rb9izv70kXfrGS UHyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=4xAzSnXDpfOfVpOQ6oyKpQH0yo38CWH808cRQGG7apw=; b=fsvI1dKVmdEzTMDciwBZqExPFecOWTuo2cFg791BUgh9vtZjqvTjhnxyMY4YHnG1/W +qRENb6DRVBHtJihYmIsjxY6hEnDcG5+8QTG2e/rPUQ4vmTSgJkMBL25KSpcCiIpeXlF r0PBgKM+3tHeNZsoZmmPwQ04aS1CLi9YEhlpP5Dm8vu6iFRqlDqwfrp8m3bJzHKjd4eM 4Bbr4ShhbEOvBUgWuA13KJ2tUFJkPsrDCgw59uU9WfTehedfv42JWcAHYKOZi88xAYEr nrjBYp8RP0eU9iBlRatNl3eOuSwMRL5Ud7LsJ/VX3rAMlZ5Sykq1sd/p+s0d7mGll7Nv mXWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GbmnqdHB; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x63si6903412itf.74.2017.11.23.10.33.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:33:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GbmnqdHB; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIZ-0005RS-VC; Thu, 23 Nov 2017 18:32:31 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIY-0005Nz-JJ for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:30 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id F5/ED-27709-E34171A5; Thu, 23 Nov 2017 18:32:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsXiVRvkqGsrIh5 lMP0gr8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvH2y0v2go+KFQ8nPGduYPwm0cXIxSEkMJFR 4vr146wgDovAPGaJo1O/MIM4EgL9rBLn218CZTiBnDyJJ1+WMEPYaRJbe+dC2ZUSbfs+AtkcQ KPUJNa8iYKY2sck8fNgIytInE1AR2LdjFqQchEBaYlrny8zgtjMAvESj6deZwOxhQVSJdYu2w 5mswioSmy7eRnM5hWwlfi+4go7xCp5iV1tF8HO4QSKHz3wAWqtjcTnz4oTGAUXMDKsYtQoTi0 qSy3SNTLRSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQIDDcGINjBuO9j5CFGSQ4m JVFemV9iUUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeG8KiUcJCRalpqdWpGXmAAMfJi3BwaMkw rsdJM1bXJCYW5yZDpE6xWjJsW/PrT9MHM9mvm5g5ph2tbWJWYglLz8vVUqcdzNIgwBIQ0ZpHt w4WHReYpSVEuZlBDpQiKcgtSg3swRV/hWjOAejkjDvW5ApPJl5JXBbXwEdxAR00M/jwiAHlSQ ipKQaGCNudc+vzjLKOscW8Onl0ss+h8ols1SZIqymrGCpuSec/Tise9aprX9lv8SsNy2fPW15 9Fv/BQZt1w0Uu3cGW1+oepXr8kKKbYHivgWsr8rEdZ5+j5tlWi+y54Ee6/4NO9u8W6L1ZzltM v/8mVdsvYZPVcGnmwfPKGgdWpJooHro77RDm6497FZiKc5INNRiLipOBACtHwYfyQIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1511461949!117542641!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17747 invoked from network); 23 Nov 2017 18:32:29 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:29 -0000 Received: by mail-wm0-f65.google.com with SMTP id r68so18457122wmr.1 for ; Thu, 23 Nov 2017 10:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p7mIpd+LKbbnz3Q6Ip8QWRoPh1RWI6NlPgc/wD0uX6c=; b=GbmnqdHBV34f+GsJNdWxaJcDOubRUh2OuW5FENEKP8Jop7POijilUeQz5WyrGBT+DW z6YQVRW4t5A/UD653AdTnEJ8iMrSYHS+4VCFgMYRbKxyycXpm57xzCNlDROH3WS3hinz rVlVZIg0Ntvijm/knijCsTgNXkbIBgs7+Bp4s= 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:in-reply-to :references; bh=p7mIpd+LKbbnz3Q6Ip8QWRoPh1RWI6NlPgc/wD0uX6c=; b=Vy8wps1tZr3J4Vb9U8uiCsx/WGi4jsMAoQcJF0J8XWpB658LBP2Aai54wt7vrtfEv3 q0g05RZTXXWcB3mG7/ypVBQVlSmWa7xAClh5i5rLaJy6tWoPlDyiyjfwRBjTF6TX9dCG UDszyHxTmYe2qh/tkfmSbQH+Cmtq+5fxtdUwXQ9ugX2iMGEfnuAkwIQZiRjlKdyd9vmE qRytwLSD7APqL/PqG7XObraWYTWiIubFvOuTgIArxLNbacGTjwcfreH0Kt1r7YiIOq9F 79FHSodJcS0/EdFrOF+OfA1wWQtM0913WA38q8veryJhNRVFmra6TMWScuUx+1+ht2k5 3t0Q== X-Gm-Message-State: AJaThX5SWhCZrKpy7pH27Q+uCmKbpzZrP4L+HQV5SXhMEDMh3VNYp4El 19Cs2URCWi+AArbao8VG5tJd5Nb0Sf4= X-Received: by 10.28.27.206 with SMTP id b197mr7580768wmb.96.1511461948624; Thu, 23 Nov 2017 10:32:28 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:28 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:09 +0000 Message-Id: <20171123183210.12045-16-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 15/16] xen/arm: traps: Move the definition of mmio_info_t in try_handle_mmio X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" mmio_info_t is currently filled by do_trap_data_guest_abort but only important when emulation an MMIO region. A follow-up patch will merge stage-2 prefetch abort and stage-2 data abort in a single helper. To prepare that, mmio_info_t is now filled by try_handle_mmio. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/traps.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index e30dd9b7e2..a68e01b457 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1936,9 +1936,14 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, } static bool try_handle_mmio(struct cpu_user_regs *regs, - mmio_info_t *info) + const union hsr hsr, + paddr_t gpa) { - const struct hsr_dabt dabt = info->dabt; + const struct hsr_dabt dabt = hsr.dabt; + mmio_info_t info = { + .gpa = gpa, + .dabt = dabt + }; int rc; /* stage-1 page table should never live in an emulated MMIO region */ @@ -1956,7 +1961,7 @@ static bool try_handle_mmio(struct cpu_user_regs *regs, if ( check_workaround_766422() && (regs->cpsr & PSR_THUMB) && dabt.write ) { - rc = decode_instruction(regs, &info->dabt); + rc = decode_instruction(regs, &info.dabt); if ( rc ) { gprintk(XENLOG_DEBUG, "Unable to decode instruction\n"); @@ -1964,7 +1969,7 @@ static bool try_handle_mmio(struct cpu_user_regs *regs, } } - return !!handle_mmio(info); + return !!handle_mmio(&info); } /* @@ -2002,7 +2007,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, const struct hsr_dabt dabt = hsr.dabt; int rc; vaddr_t gva; - mmio_info_t info; + paddr_t gpa; uint8_t fsc = hsr.dabt.dfsc & ~FSC_LL_MASK; mfn_t mfn; @@ -2013,15 +2018,13 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, if ( dabt.eat ) return __do_trap_serror(regs, true); - info.dabt = dabt; - gva = get_hfar(true /* is_data */); if ( hpfar_is_valid(dabt.s1ptw, fsc) ) - info.gpa = get_faulting_ipa(gva); + gpa = get_faulting_ipa(gva); else { - rc = gva_to_ipa(gva, &info.gpa, GV2M_READ); + rc = gva_to_ipa(gva, &gpa, GV2M_READ); /* * We may not be able to translate because someone is * playing with the Stage-2 page table of the domain. @@ -2042,7 +2045,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, .kind = dabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla }; - p2m_mem_access_check(info.gpa, gva, npfec); + p2m_mem_access_check(gpa, gva, npfec); /* * The only way to get here right now is because of mem_access, * thus reinjecting the exception to the guest is never required. @@ -2054,7 +2057,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, * Attempt first to emulate the MMIO as the data abort will * likely happen in an emulated region. */ - if ( try_handle_mmio(regs, &info) ) + if ( try_handle_mmio(regs, hsr, gpa) ) { advance_pc(regs, hsr); return; @@ -2065,11 +2068,11 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, * with the Stage-2 page table. Walk the Stage-2 PT to check * if the entry exists. If it's the case, return to the guest */ - mfn = gfn_to_mfn(current->domain, gaddr_to_gfn(info.gpa)); + mfn = gfn_to_mfn(current->domain, gaddr_to_gfn(gpa)); if ( !mfn_eq(mfn, INVALID_MFN) ) return; - if ( try_map_mmio(gaddr_to_gfn(info.gpa)) ) + if ( try_map_mmio(gaddr_to_gfn(gpa)) ) return; break; @@ -2079,7 +2082,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, } gdprintk(XENLOG_DEBUG, "HSR=0x%x pc=%#"PRIregister" gva=%#"PRIvaddr - " gpa=%#"PRIpaddr"\n", hsr.bits, regs->pc, gva, info.gpa); + " gpa=%#"PRIpaddr"\n", hsr.bits, regs->pc, gva, gpa); inject_dabt_exception(regs, gva, hsr.len); } From patchwork Thu Nov 23 18:32:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119526 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172657edl; Thu, 23 Nov 2017 10:33:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMaAtX4b8kA3xiI9m6ES4OuzOjW7ic0/Pkcsas7InEm0PdkOfbTClVNnL1Ultg42Oe/ngatV X-Received: by 10.36.1.4 with SMTP id 4mr13166257itk.59.1511462032861; Thu, 23 Nov 2017 10:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462032; cv=none; d=google.com; s=arc-20160816; b=BzdlIUaxHTM2LuW33HSMIMcobTF1oRl+8Bxu3lLLmwTxE8Yh5hpK0ayNxw4L/JeEiN 4gjo3/+fLk96FJVLraHjrPlVOksofu5yGnkntkdcHTjIjRxE+ClBOEXhOzxHlslJJn0n INPv7lVCL9sZpkahorJI8Y7MsJO+yW3R2yRHcwEdcpEo3fKCgD2YTKJuqkCLyhPc1isA j9S7FbBAyMiLf7ao3piTEH1A0xGtYXg7NxdFyjitKNwSQ0khP8w778j2Vcm1KY7+1vC3 c1Ky7pfLPrx7Q5AaTNQG9zUGsAfA3oz+yq2omIfDOW/HpCdMxv9Zos5P9y4PVu6lETK6 siVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=U2AWX02EH8eIbOq6bax8bnIotYwyIZfkl3ezXgscaZ0=; b=gr2qWWrncSMAdeeex53fr/ht4mBNH41BK51lmIznEw3tkd1jLeMKFqt59TDq0T7fT6 xWokTzSo7tn6phAAPaWsysdR2JyPenbLOMSOkGod2scKNm6p7Ti2XjC2VJ28t+73gP0q COHI7dkd6zJZtg7x0XrgQUhpWp3mAVVQfR9IP2IcuwlkVLyomNAOKWx/KD6YjsfT6uth rE/aLZ4n84AaCM8kQoZDLBEHQbhkwvbP+1aDrf/rxY4v0rEKPuONcvlIEuoBoBcLFVJ7 SkDh4ASNRVtm4Eniq1ncc4/0yj1PDKTI6sxAYFZQgjV+hDZbIMRxMvppIVn8nwkh9Dms kuaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AWq8n3z3; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 19si15883247ioi.205.2017.11.23.10.33.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:33:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AWq8n3z3; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIa-0005S7-6d; Thu, 23 Nov 2017 18:32:32 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIZ-0005Ll-3G for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:31 +0000 Received: from [85.158.143.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-4.bemta-6.messagelabs.com id D1/C8-08078-E34171A5; Thu, 23 Nov 2017 18:32:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsXiVRvkrGsnIh5 lcGUjl8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmtHyZxNjwW/birarq1kbGN9rdzFycggJTGKU uDPZv4uRi4NFYB6zxIKlh5lAHAmBflaJ/s6t7CBVEgJ5ElsnL2SGsNMk7u09wARhl0n0nJ0DV MMBNElNYs2bKJBeIYE+JokX72aygMTZBHQk1s2oBSkXEZCWuPb5MiOIzSwQL/F46nU2EFtYIE fiwNf7YDaLgKpE9/nvYDW8ArYSUw8+gTpBXmJX20VWEJsTKH70wAdmiLU2Ep8/K05gFFzAyLC KUaM4tagstUjXyFgvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMw2BiAYAfjn/mB hxglOZiURHllfolFCfEl5adUZiQWZ8QXleakFh9ilOHgUJLgvSkkHiUkWJSanlqRlpkDDHuYt AQHj5II7xJhoDRvcUFibnFmOkTqFKMlx749t/4wcTyb+bqBmWPa1dYmZiGWvPy8VClxXk+QBg GQhozSPLhxsNi8xCgrJczLCHSgEE9BalFuZgmq/CtGcQ5GJWHetyBX8WTmlcBtfQV0EBPQQT+ PC4McVJKIkJJqYGSyDG+uar8ZWFO/5Fz+b430a92t8yoEmho1z0r96vpzyVtXOb3o0LNGpu7O wzvKKvYtzGid7dNy6/A3xpblAT84D3zttUjkZZ5UOqf1bZFbv2fzFanDK0U5GK7KfJgntLQ6K vadZUXG4U3mPyM71677/GjlWpblOVvZmT2EnMpuzbL40m9eqsRSnJFoqMVcVJwIAOCWHgvIAg AA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-4.tower-21.messagelabs.com!1511461950!76915742!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60401 invoked from network); 23 Nov 2017 18:32:30 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-4.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:30 -0000 Received: by mail-wm0-f67.google.com with SMTP id g130so18043946wme.0 for ; Thu, 23 Nov 2017 10:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ynYblQUhdqBtIVnTU1fVzOwg+RNn3hpgKH19bHW2IZU=; b=AWq8n3z3C9R6n/d2mU/r6Xfx1QQFjMcI54W1wbOyJ9DM8aLAQSYdhtMh4wYCeeVD4D LBapNWsgbEpaYE4a/JeReIoh2CmsewbW+Q21ns8aD1qIlQzdYLKBgIPzMWuRzxGmjhIW NDUHDtnQcYUYP7Wsoipse42/5Az/2m9nulMQ0= 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:in-reply-to :references; bh=ynYblQUhdqBtIVnTU1fVzOwg+RNn3hpgKH19bHW2IZU=; b=o5E6PT3gSGK0OfF2tD13ZS4qhAIwYUNulKoIxFjodNxh9WI5gx31opjC7a8rYt2ZBR 0SIJwsvu/x635NJzvdRptvR0DCQKoOV7g68ZEwIn26USx1gYpQvj14tgyvRP+8hFaQz1 0kdbh3z9vSWm8X1qM6+I9PWCqxTVZuNpdPTIyzcBwFmvZPH6TFuCwekDJapxl6VEUQxy K5NKESAqST1wevYwT41nvfwHVrkh1keUOiWpndRserucCpabSY5gC2qheuJS9aLtiu8J 5FkebKPoGTOxA0I9cDFeMwTroVFqZz2hjNigBcZ9W2apxrKjT2FdnJbohwtT65KhCWYC PRdQ== X-Gm-Message-State: AJaThX49XUyrONyoASeAjCzBC9SIsL4tKqyM3p+z5x5RQL0fkjP2zMd6 aMRBq7/dh3U9qNI2pWaw4r5vJ29zi/I= X-Received: by 10.28.8.80 with SMTP id 77mr7078912wmi.135.1511461949410; Thu, 23 Nov 2017 10:32:29 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:28 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:10 +0000 Message-Id: <20171123183210.12045-17-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 16/16] xen/arm: traps: Merge do_trap_instr_abort_guest and do_trap_data_abort_guest X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The two helpers do_trap_instr_abort_guest and do_trap_data_abort_guest are used trap stage-2 abort. While the former is only handling prefetch abort and the latter data abort, they are very similarly and does not warrant to have separate helpers. For instance, merging the both will make easier to maintain stage-2 abort handling. So consolidate the two helpers in a new helper do_trap_stage2_abort. Signed-off-by: Julien Grall --- xen/arch/arm/traps.c | 133 ++++++++++++++++----------------------------------- 1 file changed, 41 insertions(+), 92 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index a68e01b457..b83a2d9244 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1862,79 +1862,6 @@ static inline bool hpfar_is_valid(bool s1ptw, uint8_t fsc) return s1ptw || (fsc == FSC_FLT_TRANS && !check_workaround_834220()); } -static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, - const union hsr hsr) -{ - int rc; - register_t gva; - uint8_t fsc = hsr.iabt.ifsc & ~FSC_LL_MASK; - paddr_t gpa; - mfn_t mfn; - - gva = get_hfar(false /* is_data */); - - /* - * If this bit has been set, it means that this instruction abort is caused - * by a guest external abort. We can handle this instruction abort as guest - * SError. - */ - if ( hsr.iabt.eat ) - return __do_trap_serror(regs, true); - - - if ( hpfar_is_valid(hsr.iabt.s1ptw, fsc) ) - gpa = get_faulting_ipa(gva); - else - { - /* - * Flush the TLB to make sure the DTLB is clear before - * doing GVA->IPA translation. If we got here because of - * an entry only present in the ITLB, this translation may - * still be inaccurate. - */ - flush_tlb_local(); - - /* - * We may not be able to translate because someone is - * playing with the Stage-2 page table of the domain. - * Return to the guest. - */ - rc = gva_to_ipa(gva, &gpa, GV2M_READ); - if ( rc == -EFAULT ) - return; /* Try again */ - } - - switch ( fsc ) - { - case FSC_FLT_PERM: - { - const struct npfec npfec = { - .insn_fetch = 1, - .gla_valid = 1, - .kind = hsr.iabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla - }; - - p2m_mem_access_check(gpa, gva, npfec); - /* - * The only way to get here right now is because of mem_access, - * thus reinjecting the exception to the guest is never required. - */ - return; - } - case FSC_FLT_TRANS: - /* - * The PT walk may have failed because someone was playing - * with the Stage-2 page table. Walk the Stage-2 PT to check - * if the entry exists. If it's the case, return to the guest - */ - mfn = gfn_to_mfn(current->domain, _gfn(paddr_to_pfn(gpa))); - if ( !mfn_eq(mfn, INVALID_MFN) ) - return; - } - - inject_iabt_exception(regs, gva, hsr.len); -} - static bool try_handle_mmio(struct cpu_user_regs *regs, const union hsr hsr, paddr_t gpa) @@ -1946,6 +1873,8 @@ static bool try_handle_mmio(struct cpu_user_regs *regs, }; int rc; + ASSERT(hsr.ec == HSR_EC_DATA_ABORT_LOWER_EL); + /* stage-1 page table should never live in an emulated MMIO region */ if ( dabt.s1ptw ) return false; @@ -2001,29 +1930,43 @@ static bool try_map_mmio(gfn_t gfn) return !map_regions_p2mt(d, gfn, 1, mfn, p2m_mmio_direct_c); } -static void do_trap_data_abort_guest(struct cpu_user_regs *regs, - const union hsr hsr) +static void do_trap_stage2_abort_guest(struct cpu_user_regs *regs, + const union hsr hsr) { - const struct hsr_dabt dabt = hsr.dabt; + /* + * The encoding of hsr_iabt is a subset of hsr_dabt. So use + * hsr_dabt to represent an abort fault. + */ + const struct hsr_xabt xabt = hsr.xabt; int rc; vaddr_t gva; paddr_t gpa; - uint8_t fsc = hsr.dabt.dfsc & ~FSC_LL_MASK; + uint8_t fsc = xabt.fsc & ~FSC_LL_MASK; mfn_t mfn; + bool is_data = (hsr.ec == HSR_EC_DATA_ABORT_LOWER_EL); /* - * If this bit has been set, it means that this data abort is caused - * by a guest external abort. We treat this data abort as guest SError. + * If this bit has been set, it means that this stage-2 abort is caused + * by a guest external abort. We treat this stage-2 abort as guest SError. */ - if ( dabt.eat ) + if ( xabt.eat ) return __do_trap_serror(regs, true); - gva = get_hfar(true /* is_data */); + gva = get_hfar(is_data); - if ( hpfar_is_valid(dabt.s1ptw, fsc) ) + if ( hpfar_is_valid(xabt.s1ptw, fsc) ) gpa = get_faulting_ipa(gva); else { + /* + * Flush the TLB to make sure the DTLB is clear before + * doing GVA->IPA translation. If we got here because of + * an entry only present in the ITLB, this translation may + * still be inaccurate. + */ + if ( !is_data ) + flush_tlb_local(); + rc = gva_to_ipa(gva, &gpa, GV2M_READ); /* * We may not be able to translate because someone is @@ -2039,10 +1982,11 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, case FSC_FLT_PERM: { const struct npfec npfec = { - .read_access = !dabt.write, - .write_access = dabt.write, + .insn_fetch = !is_data, + .read_access = is_data && !hsr.dabt.write, + .write_access = is_data && !hsr.dabt.write, .gla_valid = 1, - .kind = dabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla + .kind = xabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla }; p2m_mem_access_check(gpa, gva, npfec); @@ -2056,8 +2000,10 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, /* * Attempt first to emulate the MMIO as the data abort will * likely happen in an emulated region. + * + * Note that emulated region cannot be executed */ - if ( try_handle_mmio(regs, hsr, gpa) ) + if ( is_data && try_handle_mmio(regs, hsr, gpa) ) { advance_pc(regs, hsr); return; @@ -2072,18 +2018,21 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, if ( !mfn_eq(mfn, INVALID_MFN) ) return; - if ( try_map_mmio(gaddr_to_gfn(gpa)) ) + if ( is_data && try_map_mmio(gaddr_to_gfn(gpa)) ) return; break; default: - gprintk(XENLOG_WARNING, "Unsupported DFSC: HSR=%#x DFSC=%#x\n", - hsr.bits, dabt.dfsc); + gprintk(XENLOG_WARNING, "Unsupported FSC: HSR=%#x DFSC=%#x\n", + hsr.bits, xabt.fsc); } gdprintk(XENLOG_DEBUG, "HSR=0x%x pc=%#"PRIregister" gva=%#"PRIvaddr " gpa=%#"PRIpaddr"\n", hsr.bits, regs->pc, gva, gpa); - inject_dabt_exception(regs, gva, hsr.len); + if ( is_data ) + inject_dabt_exception(regs, gva, hsr.len); + else + inject_iabt_exception(regs, gva, hsr.len); } static void enter_hypervisor_head(struct cpu_user_regs *regs) @@ -2216,11 +2165,11 @@ void do_trap_guest_sync(struct cpu_user_regs *regs) case HSR_EC_INSTR_ABORT_LOWER_EL: perfc_incr(trap_iabt); - do_trap_instr_abort_guest(regs, hsr); + do_trap_stage2_abort_guest(regs, hsr); break; case HSR_EC_DATA_ABORT_LOWER_EL: perfc_incr(trap_dabt); - do_trap_data_abort_guest(regs, hsr); + do_trap_stage2_abort_guest(regs, hsr); break; default: