Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2479534pxb; Tue, 23 Feb 2021 08:03:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2j6dAXYe+u5qQ5dGeaupAbrNUo3hUgWW7IASwXngmRRQR4RQTs5XjI9zZ5X4lxO7UTjvd X-Received: by 2002:a5d:4b50:: with SMTP id w16mr19039834wrs.34.1614096189527; Tue, 23 Feb 2021 08:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614096189; cv=none; d=google.com; s=arc-20160816; b=eqBXG/XFsOx2Oa8sINTct74XmqRGLMBt/hInWNTXRPFaDVTuxfbpRLGgzae61LoL9D Z6dDqXKwAtKuWPQ+dR4php+dovfg/CoUdm1hwqZ8Gdmfin0ygF4I2brcaraJtUE/Ldjb Z+LyTrXRfgkwX3VX47qRObCsuJwDG/eypBJBR6Aescw2MQsUt5SuCj2W4e18Mxui3jaD OElZEUgO8CJoiPPHpol8N6KfbUNvVfSeuQWWJH/FVsu9DTQsOVDjirgrrN7ALQ+5xe20 CecrJW2/joq59wJE9XjJo7dHDKNPdTqNpPIadyW/TwlRTEInIEU2rUoRkS8i2I3i13mg uwCg== 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=Yq3UF/O6ghf1oapvxUJWBbk4uV2Kh5VLtR3aNkbqwLU=; b=k/qKaEu2mBj+YkcE5GW62ZkOIfWS5V2HsnrJFCMZ/iWYt9EG4wPNs+t80B1Nj4gbZD mFCbqaa3TipOprqiQIyiiRX6ZrNMVXuAPucBGAufTYGzXLhbFnbO6Jl8mLiidHHUSh6e MrSOa9xmN0vafdmW9FiahWu5DDeymKvufDYjZXaxgqcCF/nM/q/mr8UAfrmFDRTNe2DG +go3b+xduQpcc/Hg3AKcY8j105qZXDdy+Cp/yg6hE9yUKKULaHZ9J0i7V8o64RKDoFbI lAUGCGJUv8AtYmjJ1htIy2rQeD81/cru8fvlh10DQPhDxPnfH6JTmxYMVFE1HL6NBtfx Qt2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gpmDUt1O; 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 cq14si14545637edb.499.2021.02.23.08.02.36; Tue, 23 Feb 2021 08:03:09 -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=gpmDUt1O; 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 S233257AbhBWP7C (ORCPT + 99 others); Tue, 23 Feb 2021 10:59:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbhBWP6z (ORCPT ); Tue, 23 Feb 2021 10:58:55 -0500 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB599C06178B for ; Tue, 23 Feb 2021 07:58:10 -0800 (PST) Received: by mail-qt1-x84a.google.com with SMTP id r18so10320108qta.19 for ; Tue, 23 Feb 2021 07:58: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=Yq3UF/O6ghf1oapvxUJWBbk4uV2Kh5VLtR3aNkbqwLU=; b=gpmDUt1OHWLR5BJcB5vOUDieK/iuS3jdCYC/3Qqk1Uz7Vs2ER8YjQZNbRMmIKQo9+L clTMbUAasQIAG+/2wwlNsQFJ02PnBMqvIi6KHCGECAuGcjJ0oI2y9NG0+dkHVuJ5BKS4 Kj6fuXxVv9YctZ65M/d5X7k/HrVi8qZpi5B8Rf2pmkWcerPU6Rxm8MqW+5dFXgoOk4gX XgdQ8ljGq5Ba9c/DWmc7qO/yMOLJieMU6kawxoFxG/XrxdhzMKdE8PZ/7YSiwNLSffpL MZx6qeh80KI6yVYxeCjr51Bucj3amveXOATtQzkmRDBdMrD4Gr8Opbew4gilcJJ3m9u1 ei4A== 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=Yq3UF/O6ghf1oapvxUJWBbk4uV2Kh5VLtR3aNkbqwLU=; b=ANi0XT02uHgTiuVZcPjSkoe4kEAsVjhZ0+hRvLTTk6odM9AYidb3quaFY8MJRWOCjJ WHf60pl2pkbANl9ZjQUY+UUcPDD9e+BOajSxgxT6U407twriR7T48+wGtW9RMYHBto66 JYI7W1/IT4EzfL1dFbcXVqx10P8zMphSawpA0Y8wLMB59Y0Verd93l7PSyT3HTGavVks 5a/iu87av5GnDICxTNnFHBp4V2LED1xYrUn0UfnU0xraYhAERbVwOfQ5/6O66HiCS3HK 4pJ7F86bVYlf5ROEnfcl5kGd+3X19w/62uTZZzMIXiJf0jHO4Jday4r/pI1h9sxv5Em/ V4sA== X-Gm-Message-State: AOAM531UdG95ABHRTUw8aRHWc7TcrSTKgT2rbH4HA/Dmjx2dM1wY9gTM 0g2rF83arfqRXwZU33mU/fkZZpyv92s= Sender: "ascull via sendgmr" X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:ad4:48c3:: with SMTP id v3mr22683374qvx.51.1614095889872; Tue, 23 Feb 2021 07:58:09 -0800 (PST) Date: Tue, 23 Feb 2021 15:57:58 +0000 In-Reply-To: <20210223155759.3495252-1-ascull@google.com> Message-Id: <20210223155759.3495252-4-ascull@google.com> Mime-Version: 1.0 References: <20210223155759.3495252-1-ascull@google.com> X-Mailer: git-send-email 2.30.0.617.g56c4b15f3c-goog Subject: [PATCH v2 3/4] KVM: arm64: Use BUG and BUG_ON in nVHE hyp From: Andrew Scull To: kvmarm@lists.cs.columbia.edu Cc: linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, julien.thierry.kdev@gmail.com, will@kernel.org, catalin.marinas@arm.com, kernel-team@android.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hyp_panic() reports the address of the panic by using ELR_EL2, but this isn't a useful address when hyp_panic() is called directly. Replace such direct calls with BUG() and BUG_ON() which use BRK to trigger and exception that then goes to hyp_panic() with the correct address. Also remove the hyp_panic() declaration from the header file to avoid accidental misuse. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_hyp.h | 1 - arch/arm64/kvm/hyp/nvhe/hyp-main.c | 2 +- arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 6 ++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h index fb8404fefd1f..746eb9a2891b 100644 --- a/arch/arm64/include/asm/kvm_hyp.h +++ b/arch/arm64/include/asm/kvm_hyp.h @@ -95,7 +95,6 @@ u64 __guest_enter(struct kvm_vcpu *vcpu); bool kvm_host_psci_handler(struct kvm_cpu_context *host_ctxt); -void __noreturn hyp_panic(void); #ifdef __KVM_NVHE_HYPERVISOR__ void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr, u64 elr, u64 par); diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index a906f9e2ff34..9f37a4240562 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -181,6 +181,6 @@ void handle_trap(struct kvm_cpu_context *host_ctxt) handle_host_smc(host_ctxt); break; default: - hyp_panic(); + BUG(); } } diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-smp.c b/arch/arm64/kvm/hyp/nvhe/hyp-smp.c index 2997aa156d8e..4495aed04240 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-smp.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-smp.c @@ -18,8 +18,7 @@ u64 __ro_after_init hyp_cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID u64 cpu_logical_map(unsigned int cpu) { - if (cpu >= ARRAY_SIZE(hyp_cpu_logical_map)) - hyp_panic(); + BUG_ON(cpu >= ARRAY_SIZE(hyp_cpu_logical_map)); return hyp_cpu_logical_map[cpu]; } @@ -30,8 +29,7 @@ unsigned long __hyp_per_cpu_offset(unsigned int cpu) unsigned long this_cpu_base; unsigned long elf_base; - if (cpu >= ARRAY_SIZE(kvm_arm_hyp_percpu_base)) - hyp_panic(); + BUG_ON(cpu >= ARRAY_SIZE(kvm_arm_hyp_percpu_base)); cpu_base_array = (unsigned long *)hyp_symbol_addr(kvm_arm_hyp_percpu_base); this_cpu_base = kern_hyp_va(cpu_base_array[cpu]); -- 2.30.0.617.g56c4b15f3c-goog