From patchwork Fri Feb 5 22:56:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 377021 Delivered-To: patch@linaro.org Received: by 2002:a17:906:48d2:0:0:0:0 with SMTP id d18csp2586615ejt; Fri, 5 Feb 2021 15:20:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxP/D8y2kJYlyptTpt8pD+VWGSNO5JH1ZNpRmuX2paJEu440mavfapVNCzMU4t/HBIcfHHB X-Received: by 2002:a25:d683:: with SMTP id n125mr10050332ybg.256.1612567247757; Fri, 05 Feb 2021 15:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612567247; cv=none; d=google.com; s=arc-20160816; b=p1EzLf30hKpLMyhkXl27Hds2m6lnbgavR2dXMVzCICyNZ0rUgk1R9i9DzYY4pOciE4 kYl6nkhHlCWWeYYfdjtXEE3dLfpvyfMwrmzudz3vg2BUZd858JCTOiudQZ6XvzHbTv0n GJwBYGyLMNsBwDcZEX+leBMBabIGhJjYNzf/c8iuiEfxTL0zML6jXEh080IYbHyg0Q7B gBfoZU2iTmOhuakat9F+NyYVDQCRsZO/yFMYvysqbWVlv9w8RGqEYNzbq7G+il9EACIs 8G9C25sKV57OP8wknKXgEyuABq1oy26XQrpLjTXoWQBNoHczy0vwy1C7cf3jiPBwIq/J 0+OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=82rA4NMUeG8/5fEhbWdreaJ+KD3ZEBUxvQx5avkDYFY=; b=Cb3B6SI1+W6CPMFWua2Ffsyb2W4u5NGs+Zt2frN7vhRUwNCQyv5qy2+hKt43xldLc5 RftVLUe/q29rsee1mbrjpbB5fp0e5lzjqFE8w4w6/5AmxIUhanDoy/8jtxBAHIrZPisy eSfGeAfJZ7aLrzpfF+NWwQFvQounEPsWJM/FjJmG9ims0/iDtCGHRPoH1ZAs+5fl5QNM oLJnH67Zh6ihOIuspTfzDheLTJG8PRBMOcVKjnhQqAhIJnDLdC2nDE1rnhTplfYjqZPX 4zhyZpHSTuzxozLgjU2wXPb3MV2I2gTEGvERBl8K8syLcudeG/5FE7SV9n4mY8adWQVL qOcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dH8WQo0A; 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=fail (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 63si9729624ybh.449.2021.02.05.15.20.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Feb 2021 15:20:47 -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=fail header.i=@linaro.org header.s=google header.b=dH8WQo0A; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8AP9-0007I5-4I for patch@linaro.org; Fri, 05 Feb 2021 18:20:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8A3G-0002iX-SX for qemu-devel@nongnu.org; Fri, 05 Feb 2021 17:58:10 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:34048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8A39-0003ce-Mw for qemu-devel@nongnu.org; Fri, 05 Feb 2021 17:58:10 -0500 Received: by mail-pg1-x533.google.com with SMTP id o7so5597709pgl.1 for ; Fri, 05 Feb 2021 14:58:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=82rA4NMUeG8/5fEhbWdreaJ+KD3ZEBUxvQx5avkDYFY=; b=dH8WQo0AEMkHhpYfM75L0jN5sZXefiPMtCOKehdbFjxLsYTw0c1BaqSALoGvprb7QB HUJH7QWCkOOFkCVhyQE7y6dPuVbQyf7gJjWezjL/7gDF53/kYnAtOUINf7dnHp5niobr sx8SEd00msNEnExaofzOG1iiPcl/Qg6btaCHgiL39KMwGUr61NeBDkJlF+UABVaLOOjk xk71ShVbcmb1vTWjfpcL9/2Gcxcg2DgT+CmU6NaX/2LI2vVJ/tIFmjoMNv1Z4kHwFNPY UN/0mlyZdQXo28v2V68QoFi0Ui3HHNKRLpONUexLkpSRUyERUTX69pMyhzozV7DuuMOF JFVA== 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=82rA4NMUeG8/5fEhbWdreaJ+KD3ZEBUxvQx5avkDYFY=; b=Is1QugGzk7BD6+xu8CYOCndfDyqNU/gO1wjUXUet+ow9JF6MTTv3N9ZQVbryYfXyHR 0gHuIh0bk96JEycANyqVWNpE/E6uu6tHGuQlmwB0KDjZ6Edhj7KvShhQWJVS2eAUeHBi Vj70OCpW5lGrmM+xDi3OqRmL4WkodycgWGx7o3lBV7E3D/iHAPFFYB3sDAXiTVchbB96 nP2rPrN82/X1l7VLK5uPfnGeqSIo6eLvFkty1qYJpwTyEW/rNdqL3GmQ3MrCtSVKgQ8n 8B7EhYJ6k4T2+6ycbKUkrflE/7hTUspZoFQ44U0h1SQGifJU5bc6NBpnyVD1Tt+9Rv8s VDEA== X-Gm-Message-State: AOAM531Bj6WK219OGKVF2UkDYSBPix7WVBrX+EQdskMhz3vHNnrlWwMO S0ZErd95o/2iFTgblSa6qVAM1kt3oQ59ChJW X-Received: by 2002:a63:4504:: with SMTP id s4mr6551341pga.284.1612565882132; Fri, 05 Feb 2021 14:58:02 -0800 (PST) Received: from localhost.localdomain (cpe-66-27-222-29.hawaii.res.rr.com. [66.27.222.29]) by smtp.gmail.com with ESMTPSA id c23sm12155149pgc.72.2021.02.05.14.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:58:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 36/46] target/arm: do not use cc->do_interrupt for KVM directly Date: Fri, 5 Feb 2021 12:56:40 -1000 Message-Id: <20210205225650.1330794-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205225650.1330794-1-richard.henderson@linaro.org> References: <20210205225650.1330794-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Claudio Fontana , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Claudio Fontana cc->do_interrupt is in theory a TCG callback used in accel/tcg only, to prepare the emulated architecture to take an interrupt as defined in the hardware specifications, but in reality the _do_interrupt style of functions in targets are also occasionally reused by KVM to prepare the architecture state in a similar way where userspace code has identified that it needs to deliver an exception to the guest. In the case of ARM, that includes: 1) the vcpu thread got a SIGBUS indicating a memory error, and we need to deliver a Synchronous External Abort to the guest to let it know about the error. 2) the kernel told us about a debug exception (breakpoint, watchpoint) but it is not for one of QEMU's own gdbstub breakpoints/watchpoints so it must be a breakpoint the guest itself has set up, therefore we need to deliver it to the guest. So in order to reuse code, the same arm_do_interrupt function is used. This is all fine, but we need to avoid calling it using the callback registered in CPUClass, since that one is now TCG-only. Fortunately this is easily solved by replacing calls to CPUClass::do_interrupt() with explicit calls to arm_do_interrupt(). Signed-off-by: Claudio Fontana Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Cc: Peter Maydell Message-Id: <20210204163931.7358-9-cfontana@suse.de> Signed-off-by: Richard Henderson --- target/arm/helper.c | 4 ++++ target/arm/kvm64.c | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 47e266d7e6..1a64bd748c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9969,6 +9969,10 @@ static void handle_semihosting(CPUState *cs) * Do any appropriate logging, handle PSCI calls, and then hand off * to the AArch64-entry or AArch32-entry function depending on the * target exception level's register width. + * + * Note: this is used for both TCG (as the do_interrupt tcg op), + * and KVM to re-inject guest debug exceptions, and to + * inject a Synchronous-External-Abort. */ void arm_cpu_do_interrupt(CPUState *cs) { diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 3c37fc4fb6..dff85f6db9 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -946,7 +946,6 @@ static void kvm_inject_arm_sea(CPUState *c) { ARMCPU *cpu = ARM_CPU(c); CPUARMState *env = &cpu->env; - CPUClass *cc = CPU_GET_CLASS(c); uint32_t esr; bool same_el; @@ -962,7 +961,7 @@ static void kvm_inject_arm_sea(CPUState *c) env->exception.syndrome = esr; - cc->do_interrupt(c); + arm_cpu_do_interrupt(c); } #define AARCH64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ @@ -1493,7 +1492,6 @@ 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); - CPUClass *cc = CPU_GET_CLASS(cs); CPUARMState *env = &cpu->env; /* Ensure PC is synchronised */ @@ -1547,7 +1545,7 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) env->exception.vaddress = debug_exit->far; env->exception.target_el = 1; qemu_mutex_lock_iothread(); - cc->do_interrupt(cs); + arm_cpu_do_interrupt(cs); qemu_mutex_unlock_iothread(); return false;