Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3811999imm; Mon, 17 Sep 2018 03:43:46 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda6qHvi9w9oPEwDOK4pDIz+4pEv5K44JIOgcp/6vjaZThvtu/xIIqpnlwEfCShmgm0bfQiw X-Received: by 2002:a62:1314:: with SMTP id b20-v6mr25682050pfj.230.1537181026869; Mon, 17 Sep 2018 03:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537181026; cv=none; d=google.com; s=arc-20160816; b=k8KskEZKrM7Qq6aICuZOVue8Z4aySuFoqdXmmIF3OcoYYQ/9CpXqY7deT40g+CkDCa zPplDowfPRz+GN8EOKcs/jOGVPd19EC4GILaX35b21+SUJhp4TAJd5M4ZXqQYuZmlr0F aAphXfqjSCDkLufK/g0Tr/XxRmgsvl9xfdI3L/JNugkPfNm9TGZqY/lCpJ9yiI7STkuJ T/Kw7UmZOD/ojJdJDJgbUJ5dLALvKHKmX0To5NL9gG/pi/KzLTmq25mcHLMyHAonQgMS dVarcqSEAPIT3n7fEEVhOl9hgNLVx/0XRab5oqXJYkdSWjH++IVqX7Vy/3eNF3IejxSg tCew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dPTb1Kbjv/d9MWetBX2P6VeXMvWJzkDdPcMn8frjuQo=; b=Q+qNMQJwfx92ARmhxlDfKuammKYF0PTH3WK3ggeVAu9iYag2CnZHUoVWt/Fvpw92zm Rh0tGbzMAukhuuV18k4lvyGAtEd730aIy4Rg/YYVKOZyCQXvQBNnsS4XR+vX72qk4Wch LZXAe697VBMkDtzVYa6mrGqJ8PK7phsb/ELleE1N4uH4L+OP1QRgSJZyBFmW+Qrpw+m/ 4pS4iPk1ez0rH+5mTmEjK/Sk8NNanUVDb7qrxzBL1PC09l1dUXQ+vZmlU7pebu6LjlFV VFNBxUlA1ODJMl6gu4K3LIlVIXzixKYqvppz6KKVA5CwGuIFzSWhMGu4peBXSHKK3wSd K9Ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v132-v6si16400901pfc.193.2018.09.17.03.43.32; Mon, 17 Sep 2018 03:43:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728500AbeIQQJw (ORCPT + 99 others); Mon, 17 Sep 2018 12:09:52 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56620 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728464AbeIQQJw (ORCPT ); Mon, 17 Sep 2018 12:09:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 753DA80D; Mon, 17 Sep 2018 03:43:04 -0700 (PDT) Received: from en101.Emea.Arm.com (en101.emea.arm.com [10.4.13.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EEE213F5BD; Mon, 17 Sep 2018 03:43:01 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, marc.zyngier@arm.com, cdall@kernel.org, eric.auger@redhat.com, pbonzini@redhat.com, rkrcmar@redhat.com, will.deacon@arm.com, catalin.marinas@arm.com, james.morse@arm.com, dave.martin@arm.com, julien.grall@arm.com, linux-kernel@vger.kernel.org, suzuki.poulose@arm.com Subject: [PATCH v5 15/18] kvm: arm64: Add 52bit support for PAR to HPFAR conversoin Date: Mon, 17 Sep 2018 11:41:37 +0100 Message-Id: <20180917104144.19188-16-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917104144.19188-1-suzuki.poulose@arm.com> References: <20180917104144.19188-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for handling 52bit addresses in PAR to HPFAR conversion. Instead of hardcoding the address limits, we now use PHYS_MASK_SHIFT. Cc: Marc Zyngier Cc: Christoffer Dall Signed-off-by: Suzuki K Poulose --- arch/arm64/include/asm/kvm_arm.h | 7 +++++++ arch/arm64/kvm/hyp/switch.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 0a37c0513ede..241d1622fa19 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -308,6 +308,13 @@ /* Hyp Prefetch Fault Address Register (HPFAR/HDFAR) */ #define HPFAR_MASK (~UL(0xf)) +/* + * We have + * PAR [PA_Shift - 1 : 12] = PA [PA_Shift - 1 : 12] + * HPFAR [PA_Shift - 9 : 4] = FIPA [PA_Shift - 1 : 12] + */ +#define PAR_TO_HPFAR(par) \ + (((par) & GENMASK_ULL(PHYS_MASK_SHIFT - 1, 12)) >> 8) #define kvm_arm_exception_type \ {0, "IRQ" }, \ diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 9d5ce1a3039a..7cc175c88a37 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -263,7 +263,7 @@ static bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar) return false; /* Translation failed, back to guest */ /* Convert PAR to HPFAR format */ - *hpfar = ((tmp >> 12) & ((1UL << 36) - 1)) << 4; + *hpfar = PAR_TO_HPFAR(tmp); return true; } -- 2.19.0