Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1257418pxf; Fri, 19 Mar 2021 03:04:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ0u/2vv7F24UySEwyEESaV1g2y3WCYkUy0yxcTD+OungL8KackGvD7Dg3PDvGhJGvdOHK X-Received: by 2002:a05:6402:22f6:: with SMTP id dn22mr8343655edb.214.1616148297407; Fri, 19 Mar 2021 03:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616148297; cv=none; d=google.com; s=arc-20160816; b=DFjbXF+LMilhffSe1+b80N3y+1hxmptZWg91ongtGkGDUnhmZ6ytKxOz0cpHp9Mmkx i7onS6vlr02TVbRgxTqs6AOn0MiLk5+bKgv6SV8jtVLU50O1/b9a1XKTgjS4JbyDpyG7 KG53k7x0dOn4Vk7N03H1Rc1bppsSQ4NLqPb1CQIGTyzaZQEKqTahVhZjw3Jbz+9Ee8Ac j7bMMu/YGXG6ME90Y0KVQozu6QnKjehqmzUGgCxu6EHom/+pGJAQgWQ1BXNSognpKusU CzI4YISkAYToNoVSUYYLg28QHEB+mRdW0l3eO7zhBp7RqoOe6/KTE6ZEjnX1+hWc8ovW IJGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=MQQAWJNa/5+Ws/h1+nY46N9BdXPhpiMcbi0Tji1hFEY=; b=ToD+e7cwqS3uQrBzMSkaPqUS80DlyA9NN6dKXZNxQFr5uh1P5EW2kb/m6p4ftg9TX/ AJlP0w9ehmkHw/5Qf5SYN2Rx6GK4kwGVEA0EknRnUhBcPe3wv7vo65BeSaDkV+Svb4Fh 7a0/wQPBSOkbx62I5YDB7vx1BVbqGPukwTSwxD6kmk4UJ5EGha0f6O6Hkkkxm+nyJbC5 gKahMqXHxFhRBHL7iyP0THbOQKk7jK3VjUTxjWwIjQ5QjBfmQ1ghwFqg8hqvAkzvZXBH u4spDuyIwasIzAfmI5FVtlGzI1bZ+5dp0pKfoZVKeGOmLQRU+u2vlygHVnLDmm7Od19e N30w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=D4UmlRHS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pw11si3857161ejb.2.2021.03.19.03.04.34; Fri, 19 Mar 2021 03:04:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=D4UmlRHS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbhCSKDU (ORCPT + 99 others); Fri, 19 Mar 2021 06:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230159AbhCSKCm (ORCPT ); Fri, 19 Mar 2021 06:02:42 -0400 Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8881C06174A for ; Fri, 19 Mar 2021 03:02:41 -0700 (PDT) Received: by mail-wm1-x34a.google.com with SMTP id a63so4395535wmd.8 for ; Fri, 19 Mar 2021 03:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MQQAWJNa/5+Ws/h1+nY46N9BdXPhpiMcbi0Tji1hFEY=; b=D4UmlRHS0y4x+R9rKJqUcRUzfcgDZJEm3qtCzw6xhI0q7wC9Z7ZlLB/qrYqG4YjQbj LLjGnLuPstfxeC5mRqOGKbiOWj6KSx8M5AIAW4uZNi+KmEBgwUJxk653Rrlyazc/ZVee THBUJw7yM949Cz+/CTmypmYNwcJyh2H3r0ybsBVkS8JDAb2SeKfUpmXnpwXiYahix9Vp FdC7sa4/Hj5scSqO6gQpP6uEQmlYad8Z8v/C3BC2ya6MgXmN64ZZy48jeQ9uR/6qEnAH gQ508Zw9N04VeMwuwyWc1shMDrLmKNe35wUDeQ9AFfFQK/SYBDaXjX2U7OsnlI6lU3VD TQzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MQQAWJNa/5+Ws/h1+nY46N9BdXPhpiMcbi0Tji1hFEY=; b=jr2DMevBVRlSyvzpukGnTFHSokaU54brVYy3hIKENqRNynbDK5LUqUQYLqxjagF4sP 5R45KbI/W6ye2Cf0xQmF1raMnR56q1biBXRyuH/nCpwOhAMThOGq3IHOMCPJYgfwjThm FFT287V75oLcvMIjOEDO70y2Ph5TNZoohTumIlPl/RcfdM4q59eOk8O1ipTnDPgpgi/4 VKI76hnwZ8i4fNLWcVzc9E7qs2RiudJUYjBesnfcIr5nVyZZkvcO4kPu/dgUQjuiHeVd LBZIXQlDg+ByIyflsAL4b3GsJZHt58zJL5pYtb+9wMaxecbQX7rjCi4NGH96z7h9SnZQ V/MA== X-Gm-Message-State: AOAM5339pKSCGxq6Bu7DERML2AT8n92zHBARjXjX9U/cG8e2Mhh0NYNn ArINTET53vHI+spwXweiN256MUvDEfyq X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a1c:400b:: with SMTP id n11mr2883266wma.167.1616148160645; Fri, 19 Mar 2021 03:02:40 -0700 (PDT) Date: Fri, 19 Mar 2021 10:01:32 +0000 In-Reply-To: <20210319100146.1149909-1-qperret@google.com> Message-Id: <20210319100146.1149909-25-qperret@google.com> Mime-Version: 1.0 References: <20210319100146.1149909-1-qperret@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v6 24/38] KVM: arm64: Refactor __populate_fault_info() From: Quentin Perret To: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Cc: android-kvm@google.com, seanjc@google.com, mate.toth-pal@arm.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, tabba@google.com, ardb@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, qperret@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor __populate_fault_info() to introduce __get_fault_info() which will be used once the host is wrapped in a stage 2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/hyp/switch.h | 28 +++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 1073f176e92c..cdf42e347d3f 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -160,18 +160,10 @@ static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar) return true; } -static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) +static inline bool __get_fault_info(u64 esr, struct kvm_vcpu_fault_info *fault) { - u8 ec; - u64 esr; u64 hpfar, far; - esr = vcpu->arch.fault.esr_el2; - ec = ESR_ELx_EC(esr); - - if (ec != ESR_ELx_EC_DABT_LOW && ec != ESR_ELx_EC_IABT_LOW) - return true; - far = read_sysreg_el2(SYS_FAR); /* @@ -194,11 +186,25 @@ static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) hpfar = read_sysreg(hpfar_el2); } - vcpu->arch.fault.far_el2 = far; - vcpu->arch.fault.hpfar_el2 = hpfar; + fault->far_el2 = far; + fault->hpfar_el2 = hpfar; return true; } +static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) +{ + u8 ec; + u64 esr; + + esr = vcpu->arch.fault.esr_el2; + ec = ESR_ELx_EC(esr); + + if (ec != ESR_ELx_EC_DABT_LOW && ec != ESR_ELx_EC_IABT_LOW) + return true; + + return __get_fault_info(esr, &vcpu->arch.fault); +} + static inline void __hyp_sve_save_host(struct kvm_vcpu *vcpu) { struct thread_struct *thread; -- 2.31.0.rc2.261.g7f71774620-goog