From patchwork Tue Dec 12 19:02: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: 121639 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4508587qgn; Tue, 12 Dec 2017 11:04:38 -0800 (PST) X-Google-Smtp-Source: ACJfBosv7mcimO4OxUeCl/E4YoU9c/9GtnonHBgUfwD/8FByDqpsm1zClaprvbjSC98aW31ISoHb X-Received: by 10.107.200.86 with SMTP id y83mr7303448iof.196.1513105478897; Tue, 12 Dec 2017 11:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513105478; cv=none; d=google.com; s=arc-20160816; b=xeOvE6ZYD3Y7kbku/xMnApDo293mpqySVxhOoaJaMpJwuomt1JCNvu6Zo8zJkDqINW hAu/zmFfhTCgRqwTellBvQIdXKoKBoEBI5u9HJ3JrFP5zYFWUhAD39t1KkneJKH66Sfi O3IQQud6FOZxUe4iXIQ2sNzfKCrIqEJGGNEHkOUhzPxcKTFsuYT9aCNGXy70MWUZQY7Q DFsUx/4bvaYhvV1+ACo8CdNe+zZJIrzWRXPiirts784i7PyXlwJL3Ku2tbgONkgVeQ4K 5cZPnTVo4gxQ4k7BkHASBPA7x+U3AalAA/JPigwzbZZ2IBEGNbIFn1qUwWbS1SG27KJ3 DUvA== 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=zVQ91kCA5fugVCwEWEQjtY0VjOR2Dw/PuR4+hAQl/+I=; b=OWKLmAst4WmJ95o4LwX6w6koL5p3VncJgzqKH/ewnRGA7CXgczLpxsytmyNzKiNAA1 VdvGvzUwHSrZZE16JFJJXGKoO9+r6IToBJRYWv07Mvwddv3+wAW0nQceNsTdVf/Qe7ci Th+NSMqnjJDkhVYvv8GynUbVsb9Wsy+u9MY77joWoxYcJvVqUSzUfVL5n+yrbSXhXN1w PbKGoYHFeoIxP8ciPQxUue5HGGdZYw7THJF9uUibCIlbyD6jkh72IsUdJ+gV7V8WvEB/ yHpQ5Cva+0hw0P9eVYcGoe/qtxuv1btYZbHNys1saXBlTdTe0Xrk/l8jfDgWXjS0QUP5 z3lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bO8V8pUn; 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 62si170502itm.135.2017.12.12.11.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:04:38 -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=bO8V8pUn; 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 1eOpow-0002RS-Vn; Tue, 12 Dec 2017 19:02:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOpov-0002QX-Pn for xen-devel@lists.xen.org; Tue, 12 Dec 2017 19:02:25 +0000 X-Inumbo-ID: ea18b679-df6e-11e7-b4a6-bc764e045a96 Received: from mail-wr0-x244.google.com (unknown [2a00:1450:400c:c0c::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ea18b679-df6e-11e7-b4a6-bc764e045a96; Tue, 12 Dec 2017 20:01:53 +0100 (CET) Received: by mail-wr0-x244.google.com with SMTP id y21so22240334wrc.1 for ; Tue, 12 Dec 2017 11:02: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=JgAkwrCOYEZme6ItEpbHZL8valMoHMrkCvfrHMHnOp4=; b=bO8V8pUnifSDcerdEUu30/wK/Lg6bJ6AOrH7zfLwMKXqlp4yu+EoRhVht/GynSZVt5 4OM/o5RHeEMHn0jbhwncTnjsXFdCdBPa9BtX8eXx9iwA+61ev5oO5nIZvMylIwnMbRDT j5p2L3yJGmqzxS5leP26Ia8sPKYrq45jN1/hM= 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=JgAkwrCOYEZme6ItEpbHZL8valMoHMrkCvfrHMHnOp4=; b=hEhQUk1WU2B4LI9alXQ675fIxufm8nBMlQULAG9IJoVAKqlE2ebf5Fe0YMZzd/DbLI KFryzI2lIB1PRifIQpTbnsrOkQ2aA9U38/QeJv3F/DP4qjmXzYuomFCMgyeKUAtr/slx e9ZYS8RLnsrTyFBSKpofkftvjP8j9w2OoNGj1bNW0fxdBiIrvjm0SyevsJD4+cVEh4Cc n7AjBXkUIoJnLLA1Jc7uea642DkNrljytuGcAAVlxwcaUgkjmfcWrZxShwDyali7vbga yJ+GzOXLk5Tbdlk1Edz8qC8xUuN64BZbXTF5+DwTGv1uLMhhfXZF8MTp4ECnkRQkbUkl JRhA== X-Gm-Message-State: AKGB3mLbVacMW+BVUZqVweCfo4DSYs6WcYGrG57AMP53sP43H6Z6Myvj D94WDQMxZmZEWzXg7MO8LR3o3TpXYrI= X-Received: by 10.223.197.131 with SMTP id m3mr5076201wrg.203.1513105343738; Tue, 12 Dec 2017 11:02:23 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n14sm207508wmh.37.2017.12.12.11.02.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:02:22 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Dec 2017 19:02:01 +0000 Message-Id: <20171212190212.5535-6-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171212190212.5535-1-julien.grall@linaro.org> References: <20171212190212.5535-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [v2 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. copy_guest is meant to be vCPU agnostic, so extend the prototype to pass the vCPU. At the same time, encapsulate the vCPU in an union to allow extension for copying from a guest domain (ipa case) in the future. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Encapsulate the vCPU in an union. - Rework the commit message --- xen/arch/arm/guestcopy.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index ff7d15380f..7e92e27beb 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -9,8 +9,18 @@ #define COPY_from_guest (0U << 1) #define COPY_to_guest (1U << 1) +typedef union +{ + struct + { + struct vcpu *v; + } gva; +} copy_info_t; + +#define GVA_INFO(vcpu) ((copy_info_t) { .gva = { vcpu } }) + static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len, - unsigned int flags) + copy_info_t info, unsigned int flags) { /* XXX needs to handle faults */ unsigned offset = addr & ~PAGE_MASK; @@ -23,7 +33,7 @@ static unsigned long copy_guest(void *buf, uint64_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(info.gva.v, addr, (flags & COPY_to_guest) ? GV2M_WRITE : GV2M_READ); if ( page == NULL ) return len; @@ -64,24 +74,27 @@ static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) { - return copy_guest((void *)from, (vaddr_t)to, len, COPY_to_guest); + return copy_guest((void *)from, (vaddr_t)to, len, + GVA_INFO(current), COPY_to_guest); } unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned len) { - return copy_guest((void *)from, (vaddr_t)to, len, + return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current), COPY_to_guest | COPY_flush_dcache); } unsigned long raw_clear_guest(void *to, unsigned len) { - return copy_guest(NULL, (vaddr_t)to, len, COPY_to_guest); + return copy_guest(NULL, (vaddr_t)to, len, GVA_INFO(current), + COPY_to_guest); } unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len) { - return copy_guest(to, (vaddr_t)from, len, COPY_from_guest); + return copy_guest(to, (vaddr_t)from, len, GVA_INFO(current), + COPY_from_guest); } /*