From patchwork Tue Dec 19 19:12:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 755973 Delivered-To: patch@linaro.org Received: by 2002:adf:b181:0:b0:336:6142:bf13 with SMTP id q1csp1602325wra; Tue, 19 Dec 2023 11:18:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/S2D1wEXwdI2xhveBpzgd08oRATv2E+dNv/OSdUzQwzjzs0aulZOWYLkYPkRRR5rICYkB X-Received: by 2002:a05:6102:14a2:b0:466:b260:6908 with SMTP id d34-20020a05610214a200b00466b2606908mr1036803vsv.36.1703013510774; Tue, 19 Dec 2023 11:18:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703013510; cv=none; d=google.com; s=arc-20160816; b=zaRx5EzQQmOVCG95BW8LE11hlZzyTFL8/z9qY6NAjN5PpYJ2V8mGNl/2ZSa1Wqon/Z qeddm3JcibsFK95d1/e8GI5UhQBOiksWm4N1sjo6l9GHWUh+9cpxy4GP3lVFvl60JmSi kMM2fF3+pR9cicV1JmS0YHIIqCXFWzD3Lro+4hRRJMrLHMCqvAvS4oKE4B1ME1mP/Iyk gu/Mg+B6o73FeWmY1GMeSjfykm1Pikk2yqffxgn2MbH/peV3jiwRMr9p5ZNijuo/xeL1 w+wuJXQpi8tneimDIzUSxSC6H/jCJNvxy/w2EJoVp3SqdJV7/0Ciq9s/IBzFVmS40DbS oK5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Kbhem3ByWXGPCcp4ptdyGn3hPusC0kTAklpx1zGjXBg=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=jEf5hUizmBe9tI3VA/k+8aUPCba5noTqITy0c+5qbidEtJ9aSUVGiA/XtJJUHLO5d1 G42Vd/eKZ9uREPfHHLg5C8hb8B6bPq1XIRI+dFE8nwhFqlxo0YsV5qCKXCaMQjeD4X7K 0m8JXVUKhpoD+LCnzB9IFPr1T6Cw41Ur8E0FC1969mY1pmfT9eImt4/FZzAvkO3KQ8EG 09WP5d9nUO5PGtQFCZMciLp7bePJ9bI76lSvW06CYTnAq7fGfCp780eEaUMoCY1K4K/F 4rmHyhzGX8o8vNbikbrjEN6qpcvdOm5hPpsiDVydfwe4KEJBYuyu7dKUqdTukYSe1Az0 S4Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2zHQWdV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s19-20020a056102301300b004668030bc6bsi1166241vsa.820.2023.12.19.11.18.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2023 11:18:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2zHQWdV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFfWq-0001pS-A8; Tue, 19 Dec 2023 14:13:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFfWm-0001l2-Kd for qemu-devel@nongnu.org; Tue, 19 Dec 2023 14:13:16 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFfWk-0001lh-Bl for qemu-devel@nongnu.org; Tue, 19 Dec 2023 14:13:16 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33664b6d6abso2681152f8f.2 for ; Tue, 19 Dec 2023 11:13:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703013193; x=1703617993; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Kbhem3ByWXGPCcp4ptdyGn3hPusC0kTAklpx1zGjXBg=; b=a2zHQWdVEUVfhGl2q7FP7dqEXSQ9suFyA1blgea3uo0yB0XGDuqek7K+cc/jObi/MT jlkod3uAqbKSigdpTkL5wEEoXCyV0m4IlUHt9kibQZTYE/zVKgpea9iLT+M7KwKRyYbH JDeDtR9VUJznFui+frBuml9U66Al06seS+GevG0Midd5AYpU7vwwTlQ28FuPyIPwWpvL YAKFles3cGrJnkslN3cgPuCBFjgIRZ6A08v6yoGA7tr0bsSzSRRZlFo3jTf2g5VM4J9m QImGR4RIxepriGSbIwj7mzeKeSAsX8r/8RpEk0PNlK8LfudKV/rWuAkB06AJEPRho+Zy Nr8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703013193; x=1703617993; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kbhem3ByWXGPCcp4ptdyGn3hPusC0kTAklpx1zGjXBg=; b=qD0sMcdcn0Yi4iFfPPihygXrDBEq6fGWpEXvuG67d+JFMCImZxyOdc3ovfvPPYhzVi aKADx4mczLvBf9B8sFowjoldNUm9rD44SGRz3yvvNBimBkN6PBMG1tnIwVUY7v18LK82 r8JdZPk4mP2K7Y5I4RZLV50Orj0Y4wApE6pqFgPTUtg0XlUPBkwqg8YqquSpLROdJpbF yuXyg7hJzauqJYoegw3o/3xwE7iO94NVugkT9Q+MButI8RNYwjkhT4Zn5rSc88YABgG5 ahMrV08MygFPZ4N/Z2diSgKzVcPFwFB9ZteuECGGJ4BpNjMR9azlQ/8Uf4XAyWqWSErt 07EQ== X-Gm-Message-State: AOJu0Yx3ZtaKmkfDe5m/7zNyGmr239C7zMJr+5kbVYSqZedqyaJUe9LG ZFpjroIJ6EnLc3lBl0VM5vUwx50AOtBKArGMolI= X-Received: by 2002:adf:ef0a:0:b0:336:77a8:3e40 with SMTP id e10-20020adfef0a000000b0033677a83e40mr242400wro.103.1703013192843; Tue, 19 Dec 2023 11:13:12 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f5-20020a5d5685000000b0033657376b62sm12007754wrv.105.2023.12.19.11.13.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 11:13:12 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/43] target/arm/kvm: Move kvm_arm_handle_debug and unexport Date: Tue, 19 Dec 2023 19:12:31 +0000 Message-Id: <20231219191307.2895919-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231219191307.2895919-1-peter.maydell@linaro.org> References: <20231219191307.2895919-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Gavin Shan Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell --- target/arm/kvm_arm.h | 9 ------ target/arm/kvm.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/kvm64.c | 70 ---------------------------------------- 3 files changed, 77 insertions(+), 79 deletions(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index ac4856cb46e..9fa9cb7f767 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -445,13 +445,4 @@ static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs) #endif -/** - * kvm_arm_handle_debug: - * @cs: CPUState - * @debug_exit: debug part of the KVM exit structure - * - * Returns: TRUE if the debug exception was handled. - */ -bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit); - #endif diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 4608bea7df4..55e1b4f26e9 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -988,6 +988,83 @@ static int kvm_arm_handle_dabt_nisv(CPUState *cs, uint64_t esr_iss, return -1; } +/** + * kvm_arm_handle_debug: + * @cs: CPUState + * @debug_exit: debug part of the KVM exit structure + * + * Returns: TRUE if the debug exception was handled. + * + * See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register + * + * To minimise translating between kernel and user-space the kernel + * ABI just provides user-space with the full exception syndrome + * register value to be decoded in QEMU. + */ +static bool kvm_arm_handle_debug(CPUState *cs, + struct kvm_debug_exit_arch *debug_exit) +{ + int hsr_ec = syn_get_ec(debug_exit->hsr); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + + /* Ensure PC is synchronised */ + kvm_cpu_synchronize_state(cs); + + switch (hsr_ec) { + case EC_SOFTWARESTEP: + if (cs->singlestep_enabled) { + return true; + } else { + /* + * The kernel should have suppressed the guest's ability to + * single step at this point so something has gone wrong. + */ + error_report("%s: guest single-step while debugging unsupported" + " (%"PRIx64", %"PRIx32")", + __func__, env->pc, debug_exit->hsr); + return false; + } + break; + case EC_AA64_BKPT: + if (kvm_find_sw_breakpoint(cs, env->pc)) { + return true; + } + break; + case EC_BREAKPOINT: + if (find_hw_breakpoint(cs, env->pc)) { + return true; + } + break; + case EC_WATCHPOINT: + { + CPUWatchpoint *wp = find_hw_watchpoint(cs, debug_exit->far); + if (wp) { + cs->watchpoint_hit = wp; + return true; + } + break; + } + default: + error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")", + __func__, debug_exit->hsr, env->pc); + } + + /* If we are not handling the debug exception it must belong to + * the guest. Let's re-use the existing TCG interrupt code to set + * everything up properly. + */ + cs->exception_index = EXCP_BKPT; + env->exception.syndrome = debug_exit->hsr; + env->exception.vaddress = debug_exit->far; + env->exception.target_el = 1; + qemu_mutex_lock_iothread(); + arm_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); + + return false; +} + int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) { int ret = 0; diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 352643e0665..6b6db9374c6 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -1121,73 +1121,3 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) } return 0; } - -/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register - * - * To minimise translating between kernel and user-space the kernel - * ABI just provides user-space with the full exception syndrome - * register value to be decoded in QEMU. - */ - -bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) -{ - int hsr_ec = syn_get_ec(debug_exit->hsr); - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - /* Ensure PC is synchronised */ - kvm_cpu_synchronize_state(cs); - - switch (hsr_ec) { - case EC_SOFTWARESTEP: - if (cs->singlestep_enabled) { - return true; - } else { - /* - * The kernel should have suppressed the guest's ability to - * single step at this point so something has gone wrong. - */ - error_report("%s: guest single-step while debugging unsupported" - " (%"PRIx64", %"PRIx32")", - __func__, env->pc, debug_exit->hsr); - return false; - } - break; - case EC_AA64_BKPT: - if (kvm_find_sw_breakpoint(cs, env->pc)) { - return true; - } - break; - case EC_BREAKPOINT: - if (find_hw_breakpoint(cs, env->pc)) { - return true; - } - break; - case EC_WATCHPOINT: - { - CPUWatchpoint *wp = find_hw_watchpoint(cs, debug_exit->far); - if (wp) { - cs->watchpoint_hit = wp; - return true; - } - break; - } - default: - error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")", - __func__, debug_exit->hsr, env->pc); - } - - /* If we are not handling the debug exception it must belong to - * the guest. Let's re-use the existing TCG interrupt code to set - * everything up properly. - */ - cs->exception_index = EXCP_BKPT; - env->exception.syndrome = debug_exit->hsr; - env->exception.vaddress = debug_exit->far; - env->exception.target_el = 1; - qemu_mutex_lock_iothread(); - arm_cpu_do_interrupt(cs); - qemu_mutex_unlock_iothread(); - - return false; -}