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)