Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4066835pxb; Tue, 17 Nov 2020 10:20:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTEqW+pjpHzZXHyi0kiqbDnazRqnP3FYX6RRSVXqQN9TsMJkEGrbEFjZeIJAGpFJ/RVKh/ X-Received: by 2002:aa7:d711:: with SMTP id t17mr22238236edq.83.1605637242605; Tue, 17 Nov 2020 10:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605637242; cv=none; d=google.com; s=arc-20160816; b=Kyx+tHr1k0AC1qlVToL+J7jUHFOzD2yOQAeSJU4wpd5S1JJqvjU756THvX7jhy0mIn Pj37JWVjNBwt9b+A5lXmIXsBZetoxNcGHBATLxr70KhOeQ47ZdB76lXR9H8vFBik2h8r Z8bEAT2zVltL5qZXLhdw2u0rUhfPxcgy2sDm4+VcM6dVTK7stqigU2JF2yhgt9eHvKZd xAFGlZJPZREfBh189WwoPYrighLK7i978siR/zLW+u8zwmCNQ1JbOZ2LIZX20uCj6hmz kCNwp2XzOBwrpdnsp7o5/Jk/FiuhgMoLXUXP8lv5Ls/RUJTwgsk3RxhRqQEglBYdqQAl 33hw== 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:sender:dkim-signature; bh=ayRqxL4G0sTBj5uvihVXjKdzy9qeF8DDVF1g7AI5ntU=; b=DFGS48wcLLZQl1C7aVEoJ4Wu8NrDi/rSVdnpoQ7OeF5+OOfnP0x4cs0kMsLG2Dnh9T pKQVGupwm0laXJ0E7o7ZKjcT6UBMRXtWkVjsiwL/4svre0n7Vf/xElS7ilVXjAWH4eLq hodvh949IF5wX3vp2uRZpaWE/mZmvYl0gNROEuBwfpuGIRdY+XU/HkqlSUVYuP6XTDJV DUAGvYPiM2X9+fcfRhlBuf6LEBQQgfpVEOZZiZ+PDrbcXSzuJeDsEVO9OIPr9J6tWAuy J++H+lUYnyRXVZl1DgP4ySCR5ag7fdaYz1QWiQVd0MkBNZBkcwany4L6FYIVhmve6kI9 xHDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=q1Y7UuuK; 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 g10si18428826edv.116.2020.11.17.10.20.19; Tue, 17 Nov 2020 10:20:42 -0800 (PST) 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=q1Y7UuuK; 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 S1731070AbgKQSRP (ORCPT + 99 others); Tue, 17 Nov 2020 13:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731051AbgKQSRM (ORCPT ); Tue, 17 Nov 2020 13:17:12 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D5EC0617A6 for ; Tue, 17 Nov 2020 10:17:11 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id x22so14616079qkb.16 for ; Tue, 17 Nov 2020 10:17:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ayRqxL4G0sTBj5uvihVXjKdzy9qeF8DDVF1g7AI5ntU=; b=q1Y7UuuK4agsFAxmEhSW2c7W+ugWmHqTFkFHYU9uxsHsHtJseCbRf0SQ7qQmqgRH0S IJ7WOXz4iTftbE6rNj/KFjacgodQVSpkxUfy87L1meiv0RTeOf2yNb41sch1llaLiN8l QJcVAb8dgtRMBXHcZkNOP6wVtXXW2xYp1z/GD3+GA/XjH6FYMBHU3xPpvtCy0VIJ0BtQ sEGxtvzteDzBTDjnjh0PUSkWyBWrP9eqltpt89XpKbvqZMDGBqolGqoEZZNhbUJBkAnZ jNgMKPq3jNgQD8MMYcnDCDKng1+LvtGR4BfGS2if1J7mwNkJdcBsKq8IyV/2THkKBMO8 9dbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ayRqxL4G0sTBj5uvihVXjKdzy9qeF8DDVF1g7AI5ntU=; b=nJI9rcXSPwNSnsO1yP9dqiIO5kNzXrGnStvND3pdjihAtXOKGnbAPZgT1OwsISDhzK +91BwLjXsrXUV25l+fV969jGoqGk4Surz0VNKPhxx8A4lNwmrbhEz6p3h0s+zeoCBbdg uca11je1gY2d86PIiZ+dYOul6CxjkrBuLQ5//hbXG9h/Yrr9ClJ5T6UDrgefXKsUdF8c RB+Mz3be0SdOu0mC1Vilft4BClLQVcoijp77LYRQUXD8zrjRVzKUX8HvRpRu6C9qwIrJ YMQ2gy3niJ9dVNsKfWnEFZZeMGPvRMasRhzf5Zo7X1WU8n5cv433MqRVUC2Re5I0mM1w lh+w== X-Gm-Message-State: AOAM532iOgkBYPRWtgW6pgs+5sviQoeBnxfM5tTz7ly8fJG921yXjmry 0V+IQvsWZfmQL/mwQSiG9f1omH4+9QtA Sender: "qperret via sendgmr" X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) (user=qperret job=sendgmr) by 2002:a05:6214:b83:: with SMTP id fe3mr531341qvb.24.1605637030158; Tue, 17 Nov 2020 10:17:10 -0800 (PST) Date: Tue, 17 Nov 2020 18:16:02 +0000 In-Reply-To: <20201117181607.1761516-1-qperret@google.com> Message-Id: <20201117181607.1761516-23-qperret@google.com> Mime-Version: 1.0 References: <20201117181607.1761516-1-qperret@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [RFC PATCH 22/27] KVM: arm64: Refactor __load_guest_stage2() From: Quentin Perret To: Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand Cc: "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , open list , "open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , kernel-team@android.com, android-kvm@google.com, Quentin Perret Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor __load_guest_stage2() to introduce __load_stage2() which will be re-used when loading the host stage 2. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 5a76358e8c7a..96843b7b6eaa 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -321,9 +321,9 @@ static __always_inline u64 kvm_get_vttbr(struct kvm_s2_mmu *mmu) * Must be called from hyp code running at EL2 with an updated VTTBR * and interrupts disabled. */ -static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu) +static __always_inline void __load_stage2(struct kvm_s2_mmu *mmu, unsigned long vtcr) { - write_sysreg(kern_hyp_va(mmu->arch)->vtcr, vtcr_el2); + write_sysreg(vtcr, vtcr_el2); write_sysreg(kvm_get_vttbr(mmu), vttbr_el2); /* @@ -334,6 +334,11 @@ static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu) asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT)); } +static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu) +{ + __load_stage2(mmu, kern_hyp_va(mmu->arch)->vtcr); +} + static inline struct kvm *kvm_s2_mmu_to_kvm(struct kvm_s2_mmu *mmu) { return container_of(mmu->arch, struct kvm, arch); -- 2.29.2.299.gdc1121823c-goog