From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F89CC2D0A3 for ; Mon, 9 Nov 2020 11:37:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3B28206B6 for ; Mon, 9 Nov 2020 11:37:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HJV9hF5k"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="IR/8H2d8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3B28206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aWYc1FKuWEl946r15KYUGYDc3VUam68K4T2OtJ9Pk+o=; b=HJV9hF5kbyUyQSs2Fh3tUbm8B 6ZgkwUu2xGRw7qEkFi1AfVS0KKd690vVouk7Qo5Sqs/+NieJOVII5fHRMLK6Nr7J7D9iNz0Cezf7X mILvsV3n67inTY6/k00IUBELyQiHvmx0iGyhtTvNX4nJSzE3HVpIAHbxxBlmWy6MsSgs6kzrlh2SS AlAbyMA7qk/nml/47xMr9mtV+06w6BjHzXsa+7eb/6oawvelMrdvqXQRY7YfHZr28w2+BJHgD6Jua rOU9REl4mAkxBFblB09wNVz/yBEPmKE3amg/vEjT2x02WA1a5WkYvl6rJJwV5TbkWk8Rzkb8KAsYU 3oHr3p1Fg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc5Tl-000664-5H; Mon, 09 Nov 2020 11:36:57 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc5QA-0004Vf-CR for linux-arm-kernel@lists.infradead.org; Mon, 09 Nov 2020 11:33:26 +0000 Received: by mail-wr1-x434.google.com with SMTP id s8so1211562wrw.10 for ; Mon, 09 Nov 2020 03:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zE87N7EsES3H9YbKeZT+RN+vHxj9ggaErIqWx8Fn12A=; b=IR/8H2d81k7uevbNNSG8f/6BB011ytztZEahIYOtxTG9ucZzbuCQnUQot12tY6naDL CYEz2nEOTBd1pg78nTX5Bo3o8X2jpF1Y/laLGLB/+T19f0ePw9rH9CK2gvkp6wlxghcC +R9Cfs1KftNnc9neG+mL20Ve32bKpvhvphb6EEVU2KmByKUjwAKj0/qG1QfAl51UpOKS YBrUUbXRXp6Z8nxY1xNbE5T2eA47j3vYo9mnfT4QatLCSCvtxKdkbm1r5cg1uH/OuaAq +Y6ZVo1P2kz/eSWjrHyDv2g+8xFZ8vlPcc6XsD4qvRxLaWD6YSgsOAQxwwEtDuxkpiBk AvSA== 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:mime-version:content-transfer-encoding; bh=zE87N7EsES3H9YbKeZT+RN+vHxj9ggaErIqWx8Fn12A=; b=ni2qI/JijkUtHTWaeCa2Fa0AitK8Xu9yql4CYkyh0b+5zMlHRqmFxXG6o1f1JghyFz yjpGvbtLBg1SURjCR8k+Y5XzmSWKdpqLtZHinKn461NYVnym5tVri15WSNcKvhI1EUGU /s7Bkfke20RzSR17fr7okHMOUou0+PdoQLMuwdKav1p2sjzZBKcAyLnCp0I8AhOcDWzz VpbIXMTEVRgHB7Md1pyBAczfAGs2GjcybXvvzVN4DmIcYKQk/1jXmN1Vu4b0rA2ZWoKI aqLzixZpgaOCMyFOp8OpIEaXDVXp+5hAardmeYRZZKGM1+n3glftDtyW5hXEeBA/AJXX UdWA== X-Gm-Message-State: AOAM530puYzhoiLNqrEffBTxvwUCV/p4o/qvDCZjS7kDpq1WZtmxcBZP ATvA6cBKsihiaRT8KDtUxS8DKg== X-Google-Smtp-Source: ABdhPJygQl8gljX5JecTMhmc7uSQ5Wg3Z2Y3ZSIC8AlADfKYvAhejYRCr2+E2yqGtTe2lcwndhvUWw== X-Received: by 2002:a5d:6ca6:: with SMTP id a6mr17359352wra.348.1604921592643; Mon, 09 Nov 2020 03:33:12 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:209d:10b7:c480:3e1f]) by smtp.gmail.com with ESMTPSA id d2sm12885131wrq.34.2020.11.09.03.33.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 03:33:11 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v1 16/24] kvm: arm64: Add offset for hyp VA <-> PA conversion Date: Mon, 9 Nov 2020 11:32:25 +0000 Message-Id: <20201109113233.9012-17-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109113233.9012-1-dbrazdil@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201109_063314_580188_B0A9AD1D X-CRM114-Status: GOOD ( 15.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kernel-team@android.com, Lorenzo Pieralisi , Andrew Walbran , Suzuki K Poulose , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a host-initialized constant to KVM nVHE hyp code for converting between EL2 linear map virtual addresses and physical addresses. Also add `__hyp_pa` macro that performs the conversion. Signed-off-by: David Brazdil --- arch/arm64/kvm/arm.c | 15 +++++++++++++++ arch/arm64/kvm/hyp/nvhe/psci.c | 3 +++ 2 files changed, 18 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 28e3bc056225..dc7d43d7785a 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1484,6 +1484,20 @@ static inline void hyp_cpu_pm_exit(void) } #endif +static void init_hyp_physvirt_offset(void) +{ + extern s64 kvm_nvhe_sym(hyp_physvirt_offset); + unsigned long kern_vaddr, hyp_vaddr, paddr; + + /* Check that kvm_arm_hyp_percpu_base has been set. */ + BUG_ON(kvm_arm_hyp_percpu_base[0] == 0); + + kern_vaddr = kvm_arm_hyp_percpu_base[0]; + hyp_vaddr = kern_hyp_va(kern_vaddr); + paddr = __pa(kern_vaddr); + CHOOSE_NVHE_SYM(hyp_physvirt_offset) = (s64)paddr - (s64)hyp_vaddr; +} + static void init_cpu_logical_map(void) { extern u64 kvm_nvhe_sym(__cpu_logical_map)[NR_CPUS]; @@ -1688,6 +1702,7 @@ static int init_hyp_mode(void) } } + init_hyp_physvirt_offset(); init_cpu_logical_map(); init_psci(); diff --git a/arch/arm64/kvm/hyp/nvhe/psci.c b/arch/arm64/kvm/hyp/nvhe/psci.c index 82d3b2c89658..b0b5df590ba5 100644 --- a/arch/arm64/kvm/hyp/nvhe/psci.c +++ b/arch/arm64/kvm/hyp/nvhe/psci.c @@ -16,6 +16,9 @@ /* Config options set by the host. */ u32 kvm_host_psci_version = PSCI_VERSION(0, 0); u32 kvm_host_psci_function_id[PSCI_FN_MAX]; +s64 hyp_physvirt_offset; + +#define __hyp_pa(x) ((phys_addr_t)((x)) + hyp_physvirt_offset) static u64 get_psci_func_id(struct kvm_cpu_context *host_ctxt) { -- 2.29.2.222.g5d2a92d10f8-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel