Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3135443pxb; Mon, 9 Nov 2020 03:39:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBkhnBPzPyfbR73BBDb/41DMulVe78cZbpG1j5BF7MlbsIDy1oPmtrLydP0RCcJPaqKN6o X-Received: by 2002:aa7:d601:: with SMTP id c1mr6654011edr.323.1604921977667; Mon, 09 Nov 2020 03:39:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604921977; cv=none; d=google.com; s=arc-20160816; b=UV6TxPCyW+yWuox3L75GncJihJZrvyDVhJJQisN0xVFIHXLeOmgG1dYBAREPsu0k+T b/c8PJCVj4gXRJ4TH6yIQfYJo2IQn0flpGXqcqPXs0elgyKaxdFcYSLohEKipXWql0Vp PFAc1Z8W2BrH2/+M8rvS8cRISsIyY5gAqwSuUoOY16sHVXopZ1qpEv7FczKDzOEVK5hL 7V3cy19g4nGEYzb+cSPW/4S5v6RmZrJBOvSaPHrk+CVFLLg1f4+0OLdWRpvZqXc4Y08j nrBOMOnL5BdNemgeHahanN9ZnpGw9gjWRYAf7Tlkudqzw9kBkoRElOoINGGzbxdWT9s1 kPsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R9d1+peEDKIDAC4BUkJrLbr91HxlsiVlv7gVncj7oJE=; b=q9krYNPLXFvvsfsx1tbWwF6HpS+KdyxA8RfiaoxFNDvztEO/iOktpLWuJadFUSIWwC /7alkUjVuaDq/AzdW0bSHjm7OTDVLy0qah2YuXxUoyZeUyEhiEvHOwIVJu3d/2PgDM+s D8y9C83ED5pImKEtgQxJ4QN9ZRjahX++c17Hx3GUabGTCrLc2jHYLIvDn/TnnKEzJDlt 8uDGQz8jTiAOkSCShzYKkGrnuph+VmbmNEnIMnYMIIMhSf8h5N75MjAAKwovIl1Zgd85 fZGmdZaQd10cIRT8RbIKrgoTh3BgVnzMNW7pT5wf7KytxA9FZwWE1xKhhg1UIGtoJPvi An9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Nlkt2NoS; 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 r2si6991067ejr.265.2020.11.09.03.39.15; Mon, 09 Nov 2020 03:39:37 -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=Nlkt2NoS; 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 S1729583AbgKILgz (ORCPT + 99 others); Mon, 9 Nov 2020 06:36:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729566AbgKILdC (ORCPT ); Mon, 9 Nov 2020 06:33:02 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0636C0613CF for ; Mon, 9 Nov 2020 03:32:59 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id s8so1210832wrw.10 for ; Mon, 09 Nov 2020 03:32:59 -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=R9d1+peEDKIDAC4BUkJrLbr91HxlsiVlv7gVncj7oJE=; b=Nlkt2NoSN06mNMUiV4czGigWOfDI7alqjAr/VMiKAFi8r6SvbUFmz5qPCSigNbzGOt CcGl9WRnVJZlERP13JXxePqpq+CU1BM2zj7a30/EIygFZ19rzJYInzQrH0Ljz4jw7llX f1jQJ0Kc8LLGgt1H2glCPIT3bTzTawZk3J/ZwhQ/dbCiyJR8NCUeqezVV4pN1JrRhYD+ 1H/QFadgpHUUQqKOgln9mSwviXlgghCm6zoyLHdi32xsm/LfSaHON6HH/BFfBXggztVp Xm6hUSHCwFGge2giBU9ofUcBQTbgyAdWT16BEx2thI/+/obwWbQx/TBHVlTa6aPc4rUM hr6w== 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=R9d1+peEDKIDAC4BUkJrLbr91HxlsiVlv7gVncj7oJE=; b=GxIIDQs1MYP+p9N6bcm28ViwroZSDagUB9KNvB2Ouk+g6rXO9daqa4saG5Sq7iIXgc 5T1jRy2FwhOLrLzs3lPhAfb4QoEWXARoP4THH2K7BpJgMUX9WHSEYiVlIOadSdDH+SEv yfO9vh3+Qu2FcaJ9LjFOmNeIs/tOXF9Kba/yMSr9aPoj08XcDYtuzmDMXpvCLvxsDBUU vk8yse8v2MwPw5S/E+lvfnNnxhZeY0Ik0cZcoj9PUWNhzKUpWVB/YTAf2/fXIvIMyqmy 3+IgopTK5fPfddrrHUWAXa++bc2alL2l13fy6SvdHkGT0HPR6fZJJexR9q+9gMyb1rMO 3XRQ== X-Gm-Message-State: AOAM532T65Cg2efs2pj+kWb+PZOhlKc0FbilMTF0o9V40GBtzdWx+isM QIRMjyLgoZe8ZTxQgscBah50lA== X-Received: by 2002:a5d:6452:: with SMTP id d18mr7927464wrw.200.1604921578344; Mon, 09 Nov 2020 03:32:58 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:209d:10b7:c480:3e1f]) by smtp.gmail.com with ESMTPSA id z14sm12812890wmc.15.2020.11.09.03.32.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 03:32:57 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , Andrew Walbran , kernel-team@android.com, David Brazdil Subject: [PATCH v1 09/24] kvm: arm64: Refactor handle_trap to use a switch Date: Mon, 9 Nov 2020 11:32:18 +0000 Message-Id: <20201109113233.9012-10-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109113233.9012-1-dbrazdil@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); + } } -- 2.29.2.222.g5d2a92d10f8-goog