From patchwork Mon Nov 16 20:43:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11910801 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, 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 6CA2BC2D0A3 for ; Mon, 16 Nov 2020 20:45:57 +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 038F52222E for ; Mon, 16 Nov 2020 20:45:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GKozbzeF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="SVWNYTmy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 038F52222E 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=3lxbIs22eeHoP3tyiG6nT5hnW7Zi4jpwo0Si6GrFtBY=; b=GKozbzeF4eUOq6X+F/ikQj3Jo wq1ofIesk2BlNin+IQtB803dfWVNN6/fcbec7V8+aAMOQB8upoijjyWk3czulwP/CMVObnlhFtIXo 25tBJxfAwPm+2+KlIKkBgBYfMVgvGwe8vqdn1ehJEuCasaZPrwM9mcQ3T2kvqR8lyStKkqdZ9chkl w5bf5hDx4CdfL1BipKh8OquYC2U8pfIqgOe3l4tjQTVA9bLWe+ZUmp3RN4Ms3istQL0Pj5yH2a/Bd pCHn+Siv62MwGLPCTmMtJsEvdcK6928j1HAuXqqLJ0/qs69VkuJ56mVLEIq/wqZcVr8gQFi2yZHPw 2ZkB3Wv7w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kelN1-0008Cf-Ix; Mon, 16 Nov 2020 20:45:04 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kelLf-0007gS-2I for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2020 20:43:40 +0000 Received: by mail-wm1-x341.google.com with SMTP id 19so607640wmf.1 for ; Mon, 16 Nov 2020 12:43:38 -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=LvORiSrCboh1zuDeFhL4WafhjrkSrBKNjZKtj5yVH3Q=; b=SVWNYTmys1SPUElJcVnpJBNBs5oAdZHAjK3TgZzZfOjpBoMW5ofiWzcyLp+qfPd/rv kxeXWJJS9SoINBmJNnMAemKZcbUNdRiA7IlqnofStvW8mTMj8VEwIz2jUvrT0dA+i3Tm g4wlHWyoFXq/VYlwRf/yPokSBq5aRO13qmCxeFQHTGJWcIal7SJ4TcO6OjHoriu8V6fW cyyMoYuEkEBo1FJfAZu0x0BSpSDtsrjoio4mZiiVcN8P7hz6TwV2xEP4L0gzcuCfGjgh C997sjV7nUnfvAYgYd5xoY0UbaWHocozO0v8uoSSRaRQAVFTZ/vfGLIexqoU652x7Lnm bqvA== 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=LvORiSrCboh1zuDeFhL4WafhjrkSrBKNjZKtj5yVH3Q=; b=h6miJqlBybLlkHjU35fbpSoWeiSfuaCkMSK5EwKh1QMatlZkfn6SDPp3xykUWCDjIB 1oEbIZKtmiZNEqg2yfWNfSd8J8TLf9lHDX9gLZ8DedZ9OIFw1EOAykyJLVP8cAUmtYyd 2HljGtsXlmBN58lyMK3XtJIOOxyd6f6MbEg/QyC/DtugUB+fC71w19mhxad7x/gyfcgK fBY9fucR99aLpumbZBkGGUeBbXEg7/+N84amVBWdn73G87QLCwll1poGMuqf1x51eapR BzkovqYWrEAYo2qyHujoEBG+AUWsAvgluuro1fd8uNNqOpyywWL3aykjzg0z8QcyDxkX XscA== X-Gm-Message-State: AOAM533xsyvJSlu8Y7wheEzCHNer6im8RBB7eDh24QrNGWjnevzkkPbx SSpdcx3E1wNHyQh6BS9hbtgiHP1scDl8LyvFpXk= X-Google-Smtp-Source: ABdhPJwOvc5dWi+xkvClKzcf/gKj3+UyZ1JtpEdN2rvPQaTpD24kr3N4TlMaKDsdi++yak8H6bPEtQ== X-Received: by 2002:a05:600c:255:: with SMTP id 21mr711033wmj.69.1605559417911; Mon, 16 Nov 2020 12:43:37 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:bc40:bd71:373a:1b33]) by smtp.gmail.com with ESMTPSA id h20sm547704wmb.29.2020.11.16.12.43.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Nov 2020 12:43:36 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 07/24] kvm: arm64: Refactor handle_trap to use a switch Date: Mon, 16 Nov 2020 20:43:01 +0000 Message-Id: <20201116204318.63987-8-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201116204318.63987-1-dbrazdil@google.com> References: <20201116204318.63987-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201116_154339_474431_5C8F1F67 X-CRM114-Status: GOOD ( 15.35 ) 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, Lorenzo Pieralisi , Andrew Walbran , Suzuki K Poulose , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Small refactor so that nVHE's handle_trap uses a switch on the Exception Class value of ESR_EL2 in preparation for adding a handler of SMC32/64. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index 411b0f652417..19332c20fcde 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -16,9 +16,9 @@ DEFINE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params); -static void handle_host_hcall(unsigned long func_id, - struct kvm_cpu_context *host_ctxt) +static void handle_host_hcall(struct kvm_cpu_context *host_ctxt) { + unsigned long func_id = host_ctxt->regs.regs[0]; unsigned long ret = 0; switch (func_id) { @@ -109,11 +109,12 @@ static void handle_host_hcall(unsigned long func_id, void handle_trap(struct kvm_cpu_context *host_ctxt) { u64 esr = read_sysreg_el2(SYS_ESR); - unsigned long func_id; - if (ESR_ELx_EC(esr) != ESR_ELx_EC_HVC64) + switch (ESR_ELx_EC(esr)) { + case ESR_ELx_EC_HVC64: + handle_host_hcall(host_ctxt); + break; + default: hyp_panic(); - - func_id = host_ctxt->regs.regs[0]; - handle_host_hcall(func_id, host_ctxt); + } }