From patchwork Tue Dec 8 14:24:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11958743 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=-16.7 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, 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 BEFFAC4361B for ; Tue, 8 Dec 2020 14:26:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 67BBA23A33 for ; Tue, 8 Dec 2020 14:26:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67BBA23A33 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=P23s8Url5aTe0OQ3IncRoFZeKo1i/AiBUe+iu+SqEsw=; b=bZnRmihhUs7IwBRIJHzHKvo9F UlmET5qSM+v0eQ4Nm7Ls9x3tGL95HmanfxkhLdmdD1HVbWxz9BCTKBc8DHdUtzDhrECFqZasWeZdJ SFjixjk8fXsWmkRbDxMoH2Vbp6HTBahc1762MNgTfpd0tPRxAdevgTEH4WVsc6wovnsx1DUCjGeaF crWZnkOJ4WR/lnCfE11U3pDeZOfDGvpqAmQrVU1EvmXpUuP8ipXexk2uXeCY4SXNffQG2cuK4ra7M 1XxaabyoVJAGJBBB2dX2rBCpq63psy2XPPgDo8znGiwQ4+vMyLI8Ely5h47bG7u5ekzwhSP0XfrF8 CcK/HTxVw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmdvo-0006sU-IU; Tue, 08 Dec 2020 14:25:32 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmdvU-0006mm-K6 for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 14:25:13 +0000 Received: by mail-wr1-x443.google.com with SMTP id c1so4466448wrq.6 for ; Tue, 08 Dec 2020 06:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f8/kp02WsOtyuCy6HonxO8TbrW5eGuVLEWwGykCnj2I=; b=cYNQMxDujCmqPGMeSjB/5132Iwcyi91EYgI1F304AcQrUlHZKwrKFnxd5VYUmZe9K3 qhfD9zstwz62Vgp0K320RLF7hLuvtr9nZDivEzCcR75CoOEA4hb3GFmeyES77O7KnMTF pAFnnE6967VFpJ/Fer47PSFKjnPHQQfe7mnE8sjmlVKr9apoDHds84eU2Nsa/WKlIBbn e+PddT+iFaoD3sljklf4jA3CdeJ4OWlAk0Nm10aXIftrVEcv1s96VvtC/zC6jeWwHJuO iIaowJGppOUfMxWaOtqumlHOPIktlTx+cXWMLrE/XMiCypkUNwIa2Z7JbNAXPdtn61gw lM5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f8/kp02WsOtyuCy6HonxO8TbrW5eGuVLEWwGykCnj2I=; b=rZbeAP/tVDlJBp/cnUWO/GzIRmmOMKiIfzD/gKWFBaLibYxKZEM7vvOkXOz2XEpNaW VVj+uIxPBYW3KHr9O7KZVAufYBNjoQckeAX11df0eOSWkzzPNxfI31YApOmWia3QdmS4 G00+hYgn4ZP3DX9GXDP67qVjDG3zPH6FxQ/6C+tJdjo0ZwYM6hKSGAnz8wCTEV832rV5 eDKCsVtrv2pcl4sw8XB2RbrXFEzWu+uClUQhTiYjy7NGnfbGBrGik5CrfVFxqse/s03B IE2/Ff6kER1yXccuKer4Vs14pMpcJKmfXcuowmgY1YqnWHzZiYo6Me8s2DLiDcKJ1izJ fy1Q== X-Gm-Message-State: AOAM533sRejRdbJ3IUq3WcFEVLwLssH88XDXswheWmNmpopvjlSUY2lv +arWbmoigVr8zcEa6QFIuLe7Ug== X-Google-Smtp-Source: ABdhPJxMNnq/XmyKaQEfovB9gUn+Z+sXBgJfo586XxWEv01Ooqibpo3M5GZvW3EusOCR/yqN4TASEg== X-Received: by 2002:a5d:69cf:: with SMTP id s15mr17334520wrw.372.1607437511630; Tue, 08 Dec 2020 06:25:11 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:258e:cb26:cef:a620]) by smtp.gmail.com with ESMTPSA id b200sm3963032wmb.10.2020.12.08.06.25.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Dec 2020 06:25:10 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 6/6] kvm: arm64: Move skip_host_instruction to adjust_pc.h Date: Tue, 8 Dec 2020 14:24:52 +0000 Message-Id: <20201208142452.87237-7-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208142452.87237-1-dbrazdil@google.com> References: <20201208142452.87237-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_092512_758892_F4ACB456 X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kernel-team@android.com, Suzuki K Poulose , Marc Zyngier , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , David Brazdil , Will Deacon , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move function for skipping host instruction in the host trap handler to a header file containing analogical helpers for guests. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 9 +++++++++ arch/arm64/kvm/hyp/nvhe/hyp-main.c | 12 ++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h index b1f60923a8fe..61716359035d 100644 --- a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h +++ b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h @@ -59,4 +59,13 @@ static inline void __adjust_pc(struct kvm_vcpu *vcpu) } } +/* + * Skip an instruction while host sysregs are live. + * Assumes host is always 64-bit. + */ +static inline void kvm_skip_host_instr(void) +{ + write_sysreg_el2(read_sysreg_el2(SYS_ELR) + 4, SYS_ELR); +} + #endif diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index bde658d51404..a906f9e2ff34 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -157,11 +157,6 @@ static void default_host_smc_handler(struct kvm_cpu_context *host_ctxt) __kvm_hyp_host_forward_smc(host_ctxt); } -static void skip_host_instruction(void) -{ - write_sysreg_el2(read_sysreg_el2(SYS_ELR) + 4, SYS_ELR); -} - static void handle_host_smc(struct kvm_cpu_context *host_ctxt) { bool handled; @@ -170,11 +165,8 @@ static void handle_host_smc(struct kvm_cpu_context *host_ctxt) if (!handled) default_host_smc_handler(host_ctxt); - /* - * Unlike HVC, the return address of an SMC is the instruction's PC. - * Move the return address past the instruction. - */ - skip_host_instruction(); + /* SMC was trapped, move ELR past the current PC. */ + kvm_skip_host_instr(); } void handle_trap(struct kvm_cpu_context *host_ctxt)