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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 34ECEC4360C for ; Wed, 10 Mar 2021 17:59:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22B5864FB2 for ; Wed, 10 Mar 2021 17:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233521AbhCJR7L (ORCPT ); Wed, 10 Mar 2021 12:59:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233711AbhCJR6r (ORCPT ); Wed, 10 Mar 2021 12:58:47 -0500 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8D56C061760 for ; Wed, 10 Mar 2021 09:58:46 -0800 (PST) Received: by mail-qv1-xf49.google.com with SMTP id j3so13296185qvo.1 for ; Wed, 10 Mar 2021 09:58:46 -0800 (PST) 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=mOohSeaIfwaEz8hEwSDUNnz+PysLBU9WmW/RUHzGWms=; b=UpCuP2JVMuI2+hVj+HMC9GepoPsIZM85HpFVq86MfaLWQfpLNX0CKray2/cYIx3hap FulboVVX/ZHpVWShTcu4rkz5liv323G1IaAkq/Q7XxYW+eVy3QOYbeogjkUE553M3PKX biChA2Ckr+PQ2tq4vQH2hsa+yxoCKi4mutHQoucMaEC1c1zTEb4ltW/vBP3L7OdS8mx1 Z+aDeD8BxzSyaR4xMCs8dlEBcK/zLbGW9ng687rwEBkWedmJU5x5I8x5pTDkDJfsOGr3 gh9NFs7XMGoW4QhnPBTufa45Fj4aVoY9kvDtdX6Mm9AoCMnRhBRJtiXHkfmQanMbjAOo Fiog== 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=mOohSeaIfwaEz8hEwSDUNnz+PysLBU9WmW/RUHzGWms=; b=lXtq93Lo35cO1yY9b+SamnFbA+Wb3zQ89BqhYebegpVSbFTxH5o2VyU3xBvybxzEGr 7wzXvK6E8wcZktcznPl9VB5IP1uYNtrZM7wtbu47HrVcDQhH3xAjaUPmedAH9foIQ3DV AhIfWZJBDr9ts+9lrQJR4QT3hQ2SXfQO4yFe1Nz0LN8Xv/ooKl0N3+n52Gj1BLYHrEYs /TjL8sbgFR3FmrwQOLoLBeUpDWrdF2CZXJuHzyR4E2jcWaTYAz6bShStDH3Z4pCnnt3V Zrw/+CxHHMKKnxzP7u3E/KDKcfEfiJ58igEQJv3y5Z5jECnBA8PxVUCbiRh2I8UjxIUl /aow== X-Gm-Message-State: AOAM532k+PQ0n3Jki1J8E7+n0R6B7n8PGLR85dd6sky74meO4c+MhbrT aTqElFJOb1Jj+LZgIqI2ZSYxcuU+bfmY X-Google-Smtp-Source: ABdhPJwx7QrSBh2ptN4PQ7VNEdb7G5Onq4cJuMCN82nqpZk0yWXTQDUEtyuol5HOBBtLBr8L8iuseENS5Fk+ X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:b894:: with SMTP id y20mr4097294qvf.43.1615399125954; Wed, 10 Mar 2021 09:58:45 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:40 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-24-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 23/34] 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, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, qperret@google.com, robh+dt@kernel.org, ardb@kernel.org 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 | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 6c1f51f25eb3..40c274da5a7c 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -160,19 +160,9 @@ 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); + fault->far_el2 = read_sysreg_el2(SYS_FAR); /* * The HPFAR can be invalid if the stage 2 fault did not @@ -188,17 +178,29 @@ static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) if (!(esr & ESR_ELx_S1PTW) && (cpus_have_final_cap(ARM64_WORKAROUND_834220) || (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) { - if (!__translate_far_to_hpfar(far, &hpfar)) + if (!__translate_far_to_hpfar(fault->far_el2, &fault->hpfar_el2)) return false; } else { - hpfar = read_sysreg(hpfar_el2); + fault->hpfar_el2 = read_sysreg(hpfar_el2); } - vcpu->arch.fault.far_el2 = far; - vcpu->arch.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); +} + /* Check for an FPSIMD/SVE trap and handle as appropriate */ static inline bool __hyp_handle_fpsimd(struct kvm_vcpu *vcpu) { -- 2.30.1.766.gb4fecdf3b7-goog 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,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 BC236C433DB for ; Wed, 10 Mar 2021 17:58:51 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 6629B64FB5 for ; Wed, 10 Mar 2021 17:58:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6629B64FB5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1C6344B635; Wed, 10 Mar 2021 12:58:51 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yb-KwdJEcDCU; Wed, 10 Mar 2021 12:58:50 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1D2774B5F7; Wed, 10 Mar 2021 12:58:50 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7A52E4B531 for ; Wed, 10 Mar 2021 12:58:49 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qYI1QcltLTlN for ; Wed, 10 Mar 2021 12:58:48 -0500 (EST) Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 79BAC4B60D for ; Wed, 10 Mar 2021 12:58:46 -0500 (EST) Received: by mail-qv1-f74.google.com with SMTP id n1so13259913qvi.4 for ; Wed, 10 Mar 2021 09:58:46 -0800 (PST) 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=mOohSeaIfwaEz8hEwSDUNnz+PysLBU9WmW/RUHzGWms=; b=UpCuP2JVMuI2+hVj+HMC9GepoPsIZM85HpFVq86MfaLWQfpLNX0CKray2/cYIx3hap FulboVVX/ZHpVWShTcu4rkz5liv323G1IaAkq/Q7XxYW+eVy3QOYbeogjkUE553M3PKX biChA2Ckr+PQ2tq4vQH2hsa+yxoCKi4mutHQoucMaEC1c1zTEb4ltW/vBP3L7OdS8mx1 Z+aDeD8BxzSyaR4xMCs8dlEBcK/zLbGW9ng687rwEBkWedmJU5x5I8x5pTDkDJfsOGr3 gh9NFs7XMGoW4QhnPBTufa45Fj4aVoY9kvDtdX6Mm9AoCMnRhBRJtiXHkfmQanMbjAOo Fiog== 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=mOohSeaIfwaEz8hEwSDUNnz+PysLBU9WmW/RUHzGWms=; b=lVsnFJVIxF03h8RHKSg1XvZvWX+bFgEj4ymTDP6NxdJQQfMHjYT3usWVMLqKofLvD8 seLVSZVY8cJRUUjcOOGDG90z6W94V1Pz4Zt6KY15WB/I0Hgik/83ZY2P7OQlzwfsU8d6 QCHkgyCICApCS3a+e7nKflUV3JgJ1kxmhLBr0Q0qCeEIBFR6mIKDiF146gBa4KfjpFZx l/d6QAE4mhCLIdrJbw6zG+WXp0QJa5EZfpi2m/Gc1tf2GT6HefiC/a/ut5eAdzjo2oXP o9ABM2D1yO9Irk5/YARy6Y7PEMapGRhLxGSzA8MBGYodJhB0fPpQNdWRsSPjxM6dMmLy 12Fg== X-Gm-Message-State: AOAM532DVmN2vmbfzj4bVcGttXIxOGJC/58UihwXQmMjLUeuCa7qP8Q2 yycu3GCY3qo0yznDH4a/myLMR5LZyIHA X-Google-Smtp-Source: ABdhPJwx7QrSBh2ptN4PQ7VNEdb7G5Onq4cJuMCN82nqpZk0yWXTQDUEtyuol5HOBBtLBr8L8iuseENS5Fk+ X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:b894:: with SMTP id y20mr4097294qvf.43.1615399125954; Wed, 10 Mar 2021 09:58:45 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:40 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-24-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 23/34] 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 X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 6c1f51f25eb3..40c274da5a7c 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -160,19 +160,9 @@ 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); + fault->far_el2 = read_sysreg_el2(SYS_FAR); /* * The HPFAR can be invalid if the stage 2 fault did not @@ -188,17 +178,29 @@ static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) if (!(esr & ESR_ELx_S1PTW) && (cpus_have_final_cap(ARM64_WORKAROUND_834220) || (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) { - if (!__translate_far_to_hpfar(far, &hpfar)) + if (!__translate_far_to_hpfar(fault->far_el2, &fault->hpfar_el2)) return false; } else { - hpfar = read_sysreg(hpfar_el2); + fault->hpfar_el2 = read_sysreg(hpfar_el2); } - vcpu->arch.fault.far_el2 = far; - vcpu->arch.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); +} + /* Check for an FPSIMD/SVE trap and handle as appropriate */ static inline bool __hyp_handle_fpsimd(struct kvm_vcpu *vcpu) { -- 2.30.1.766.gb4fecdf3b7-goog _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 7B7BEC433DB for ; Wed, 10 Mar 2021 18:07:54 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5F59664F95 for ; Wed, 10 Mar 2021 18:07:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F59664F95 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S9zLzvvTTDC/M1XL2HzC7OOL5NKLj3lkO988SuUHXQk=; b=T+3iNHsdlOvHu+ tAXWDW6NCK6Lqd8khEil+g6oQT6tl6SbqBuZgDmdipw3fOZIkUlp35P/g13rq4uNApjFgTvw4yqCj WE58YINmLe7X1M7daMljDIHIGeRkqEJn5M64DOyNt9LJsdF7pb2m9Dfpnk4+oEselyXwtu4ASDy0P IKyYo2jluzkNOxicxjo8KTYPof7sT2NMgIe2stJq5Y3t1YAisUQL9kM8tOd11diHl1TiXB9+saXac S8CB5TpbUgxW1/Xi0cabIIDUWlBRRF3TC1S2LWb55mS3PHOpkjGEEN+tfLMGqx4SoPEka1f54hcED JQ0YMN9Qi4Nhv2A73YqQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK3Dh-007RY9-HG; Wed, 10 Mar 2021 18:06:06 +0000 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK36e-007OP3-UB for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 17:58:53 +0000 Received: by mail-qt1-x84a.google.com with SMTP id k10so13482511qte.17 for ; Wed, 10 Mar 2021 09:58:46 -0800 (PST) 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=mOohSeaIfwaEz8hEwSDUNnz+PysLBU9WmW/RUHzGWms=; b=UpCuP2JVMuI2+hVj+HMC9GepoPsIZM85HpFVq86MfaLWQfpLNX0CKray2/cYIx3hap FulboVVX/ZHpVWShTcu4rkz5liv323G1IaAkq/Q7XxYW+eVy3QOYbeogjkUE553M3PKX biChA2Ckr+PQ2tq4vQH2hsa+yxoCKi4mutHQoucMaEC1c1zTEb4ltW/vBP3L7OdS8mx1 Z+aDeD8BxzSyaR4xMCs8dlEBcK/zLbGW9ng687rwEBkWedmJU5x5I8x5pTDkDJfsOGr3 gh9NFs7XMGoW4QhnPBTufa45Fj4aVoY9kvDtdX6Mm9AoCMnRhBRJtiXHkfmQanMbjAOo Fiog== 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=mOohSeaIfwaEz8hEwSDUNnz+PysLBU9WmW/RUHzGWms=; b=FXHoCcnTycxJszzikfRuWH5apFBbA27gCPWO4ncUUKtDLfBb+8yZVJgNyASQWTVy2v E/j/w8Vf8xVnVCM0WjD+jxdaizJk/A01ZyMy2SC29Y0fkEzzpuLoSpv7ZKe7VYlpJy4Z 14Epz0ZdjGQ6nE2bhxfLTDFCX2TjWkbM/GJXhZnA9y/wdy3b867aW2g0BinDWPckhNfw BOcQ5o8nr3kk609gcLBJiMoDMlxbDZmPtXMtu8fN4gcTx4ZL9mrTOVzIdCxfeCB+QtHA FOl2KBlUJTBbSqv9/RS19H9aJGjQnEwBjOuyZWWL6au6dt4aGNs8GJyb/lz/zKxAOdpF Ugug== X-Gm-Message-State: AOAM530qAYbuL/VKsiDqKeYDYWc4jq9gahZO0fEAcs7DPgFKIVZGzXFi J0L2yGoLgvIUdwfT4Pn9rIySka6Pms37 X-Google-Smtp-Source: ABdhPJwx7QrSBh2ptN4PQ7VNEdb7G5Onq4cJuMCN82nqpZk0yWXTQDUEtyuol5HOBBtLBr8L8iuseENS5Fk+ X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:b894:: with SMTP id y20mr4097294qvf.43.1615399125954; Wed, 10 Mar 2021 09:58:45 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:40 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-24-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 23/34] 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, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, qperret@google.com, robh+dt@kernel.org, ardb@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_175849_446913_0488EC9E X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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 | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 6c1f51f25eb3..40c274da5a7c 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -160,19 +160,9 @@ 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); + fault->far_el2 = read_sysreg_el2(SYS_FAR); /* * The HPFAR can be invalid if the stage 2 fault did not @@ -188,17 +178,29 @@ static inline bool __populate_fault_info(struct kvm_vcpu *vcpu) if (!(esr & ESR_ELx_S1PTW) && (cpus_have_final_cap(ARM64_WORKAROUND_834220) || (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) { - if (!__translate_far_to_hpfar(far, &hpfar)) + if (!__translate_far_to_hpfar(fault->far_el2, &fault->hpfar_el2)) return false; } else { - hpfar = read_sysreg(hpfar_el2); + fault->hpfar_el2 = read_sysreg(hpfar_el2); } - vcpu->arch.fault.far_el2 = far; - vcpu->arch.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); +} + /* Check for an FPSIMD/SVE trap and handle as appropriate */ static inline bool __hyp_handle_fpsimd(struct kvm_vcpu *vcpu) { -- 2.30.1.766.gb4fecdf3b7-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel