Received: by 10.213.65.68 with SMTP id h4csp649935imn; Tue, 27 Mar 2018 06:21:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Ce15y9JlSDaQrn28P+yG6szmnFczulHVGxfuCkHIIe8RYB8mydcO6cwK0py8XQtGXbyTS X-Received: by 2002:a17:902:7c04:: with SMTP id x4-v6mr2793373pll.142.1522156884809; Tue, 27 Mar 2018 06:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522156884; cv=none; d=google.com; s=arc-20160816; b=Obg10WY/CzWcACoXHfzZmJwnQ39o5/+HdgsnglcJABUuAxR4bJRpyQQ9EdsydoJLRp y0FoHKH/KMRlvIvazObKkZP1wO+ilDi/VjcEv6jXqQyaLbXS9wvGPLycO8HZcSDFgC7V p83OBxkW70zDbWjQJdiSby/OHWs8yQ951haKHZcAEDjIPFNkX5yKPTVZBOpiGf3uhrdH 7X/psOIVxaTvMJXq2rcsMpZR3SDJRamZl9rTgH8v1KcuglIZ4vY5YjmTyxM8fp0wZVa6 7P4zP1NisJPDwn0huUZR09xVyEwjrBEvbnW5GZX2tfz0qg7jauuuj/7iMUVD5R4AWTz1 l6Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=9fKeU/iD3Q96/IItdi4dyJDR+H9yXlxWY8SNR/z62GE=; b=U1Ds7GU2NhIim5FJz5oMR7/7u8Q+7iFCoFjjKltdn1WdRaSYdcDq+FiKkT2Yj5Ttg/ dkDHhNA4LQZUgYwXrbq/A0dXPJLYh5fE3c/lb9Bw3DU7UduXcQG5Enls5kBKbJefI1xb +MlgYhyWcDmzcGrBmDI5DpYOCyTXKFsSgf/iyfIOc7GpYor2p8zlU7XJ3Cdl3c1T63PP +yfX2H8aZAVwuBXwDHtWwd3gJOhjEk3N475uRD6f6oGjrOWtCKzyBYhP0K0HqTU74VPb E4ONCkSimgCoWQFXEJgTzqRXKC7BS0Vz4PYsR2y/bvUj1/IdoD/5W2tcvX/zXA2haskJ mlqA== 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 8si992140pfv.115.2018.03.27.06.21.10; Tue, 27 Mar 2018 06:21:24 -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 S1753028AbeC0NT0 (ORCPT + 99 others); Tue, 27 Mar 2018 09:19:26 -0400 Received: from foss.arm.com ([217.140.101.70]:55182 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752875AbeC0NQs (ORCPT ); Tue, 27 Mar 2018 09:16:48 -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 DEB941435; Tue, 27 Mar 2018 06:16:47 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 414A73F24A; Tue, 27 Mar 2018 06:16:45 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com, Suzuki K Poulose Subject: [PATCH v2 16/17] kvm: arm64: Add support for handling 52bit IPA Date: Tue, 27 Mar 2018 14:15:26 +0100 Message-Id: <1522156531-28348-17-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for handling the 52bit IPA. 52bit IPA support needs changes to the following : 1) Page-table entries - We use kernel page table helpers for setting up the stage2. Hence we don't explicit changes here 2) VTTBR:BADDR - This is already supported with : commit 529c4b05a3cb2f324aa ("arm64: handle 52-bit addresses in TTBR") 3) VGIC support for 52bit: Supported with a patch in this series. That leaves us with the handling for PAR and HPAR. This patch adds support for handling the 52bit addresses in PAR and HPFAR, which are used while handling the permission faults in stage1. Cc: Marc Zyngier Cc: Kristina Martsenko 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 2b278dc..e48852c 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -302,6 +302,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 794da55..b785853 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -241,7 +241,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.7.4