From patchwork Wed Aug 5 18:12:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702119 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2037A14DD for ; Wed, 5 Aug 2020 18:18:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 ED89F2084D for ; Wed, 5 Aug 2020 18:18:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bhggd3ul" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED89F2084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3NzW-0005LL-6v for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:18:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NyQ-0003g1-PK for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:10 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:55414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyP-0006Qg-3A for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:10 -0400 Received: by mail-pj1-x1041.google.com with SMTP id 2so5004791pjx.5 for ; Wed, 05 Aug 2020 11:17:08 -0700 (PDT) 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; bh=Cw3yBPmbCJhRgO2KPinIHhC/h5HD4KqFIy/v1BHn1wY=; b=Bhggd3ulq5KNGlj9qpCKMy3jq1VNUUSfukireTCdkVoibCCIY95b4VB79aZSdtwkta IQphqe+Y8zJlBYWP8Ontj70VFnHgHVLEukWsgAuKbANEKPuqbW5Xem5jOq63FeGsImPt kwrE3vaqJfibhmU9on03gdaMugvoqLF8ndRAs0/cM26SsODxzlrEGKim/GyNwK0R0j1B Ts/yaV3Lk1BngITshCseGrUPK6qn3BWs7qNoWZk+BjIj2GMIGgUv/Bdl8b3B7N4s7C5l OZ43BmzdedN88BUQWPcyQZkp9gsgQbtfFcKfZrjXDqJYlqVOfvEtkjkb+TIqmoeAdSqM y5Aw== 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; bh=Cw3yBPmbCJhRgO2KPinIHhC/h5HD4KqFIy/v1BHn1wY=; b=dNC+bfBlVPTPeslrjSYfM+ajoou9BS1UceSUQRWi55QebuLnArmuUBJMZQqSfX0OYE j4iktieSiWjLCwxI63wLrxQ7qQl86jGWErwMRN9HBakwfiJoEnenCyY4ufqakRcsAHtY euGe23wrGFAYMv1WgRz5NxjtqZ8BbbD2kMUCrEusf/6+hWJBLGG01W0EN2CEc7P0Z1aw uP56yUCGYggQ1JTTItm78wZXQjQ8vNHrJX+6x0UjbtKs3MuJjb9VnPa9P0bzrW96FW2x D2RpKWc/o0dEg8pjTzSl7OjVe7Jc5Skx88EYm3kLjvkvSlFTN1jxu/rTcYZNqT9AWmuV 5Z1g== X-Gm-Message-State: AOAM533l/aGQqOfmo6kJPm+LnYgDANlmA69qmT9B+nz6/+OTvYrqUN7v 2A1vQv3ZiEhwtSF0tbJ/Kfn16jvWaSY= X-Google-Smtp-Source: ABdhPJzWgLE7D3D0rQU2bBJ91EGPtUDBpTPkkmHseYYznGzyvdKE/6tsZY6NjjfGt3DZsQfwsyUGVw== X-Received: by 2002:a17:902:834a:: with SMTP id z10mr4382242pln.5.1596651427371; Wed, 05 Aug 2020 11:17:07 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:06 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 01/21] accel/tcg: Change interrupt/exception handling to remove implied BQL Date: Wed, 5 Aug 2020 14:12:43 -0400 Message-Id: <20200805181303.7822-2-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1041.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This change removes the implied BQL from the cpu_handle_interrupt, and cpu_handle_exception paths. This BQL acquire is being pushed down into the per arch implementation. Signed-off-by: Robert Foley --- accel/tcg/cpu-exec.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 80d0e649b2..8e2bfd97a1 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -517,9 +517,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) #else if (replay_exception()) { CPUClass *cc = CPU_GET_CLASS(cpu); - qemu_mutex_lock_iothread(); cc->do_interrupt(cpu); - qemu_mutex_unlock_iothread(); cpu->exception_index = -1; if (unlikely(cpu->singlestep_enabled)) { @@ -558,7 +556,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(cpu_interrupt_request(cpu))) { int interrupt_request; - qemu_mutex_lock_iothread(); + cpu_mutex_lock(cpu); interrupt_request = cpu_interrupt_request(cpu); if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ @@ -567,7 +565,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG); cpu->exception_index = EXCP_DEBUG; - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); return true; } if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) { @@ -577,13 +575,15 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT); cpu_halted_set(cpu, 1); cpu->exception_index = EXCP_HLT; - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); return true; } #if defined(TARGET_I386) else if (interrupt_request & CPU_INTERRUPT_INIT) { X86CPU *x86_cpu = X86_CPU(cpu); CPUArchState *env = &x86_cpu->env; + cpu_mutex_unlock(cpu); + qemu_mutex_lock_iothread(); replay_interrupt(); cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); @@ -595,7 +595,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); return true; } #endif @@ -604,7 +604,9 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { + cpu_mutex_unlock(cpu); if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { + cpu_mutex_lock(cpu); replay_interrupt(); /* * After processing the interrupt, ensure an EXCP_DEBUG is @@ -614,6 +616,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu->exception_index = (cpu->singlestep_enabled ? EXCP_DEBUG : -1); *last_tb = NULL; + } else { + cpu_mutex_lock(cpu); } /* The target hook may have updated the 'cpu->interrupt_request'; * reload the 'interrupt_request' value */ @@ -627,7 +631,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */ - qemu_mutex_unlock_iothread(); + cpu_mutex_unlock(cpu); } /* Finally, check if we need to exit to the main loop. */ @@ -691,7 +695,6 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, } #endif } - /* main execution loop */ int cpu_exec(CPUState *cpu) From patchwork Wed Aug 5 18:12:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702121 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D451913 for ; Wed, 5 Aug 2020 18:18:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 5AD592084D for ; Wed, 5 Aug 2020 18:18:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="h/RqssUP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AD592084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3Nze-0005Yn-Dr for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:18:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NyU-0003ln-Ov for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:14 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:34929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyR-0006Rz-RP for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:14 -0400 Received: by mail-pg1-x531.google.com with SMTP id o5so6956454pgb.2 for ; Wed, 05 Aug 2020 11:17:11 -0700 (PDT) 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; bh=4mUrzxN38KgTWVnwLLnwWRuKmcxV8e0+CR7Czj1dxnk=; b=h/RqssUPjaOf96oNkU3g32Vos9LqhECbWbowgWHUFifSflEfsOn/kL93ShZCbnRynI FegZL/HBc1U88j37iHp+whCF6yPEuSytg9vaor99axMywu+MeXWi1ObiYFZ0YGeZkd79 nOGihwnRZ7qP2tvlpripBITtBEnVQQNrtQGkOv3+3XxGILeEourfAS68aVvxZHtxaV43 oVrO2P/A0g5T0tz5IAQM+1hlrMPBOjIWeOfkGCkJLQknVOAP8oJ+IlwX60LNS+N2L3c3 kk4XQNCkZ1qpKRcW0LKd4iW6TIs579ChYJFaTKTiV5M3+jzJmu2bqibBQ7b8EwjGRDtf uIWg== 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; bh=4mUrzxN38KgTWVnwLLnwWRuKmcxV8e0+CR7Czj1dxnk=; b=NoIAWFCYabDTZTDm8yGpDLdljwcy3jxpoClq0xuKeBJs/nagAt6lzPp80A9R9oXzg5 RHTQkVwgcRRr/OouJVKqJajy6yWTB5+ZQDWPTVnyRSAi2X0Nlo+ZnQlTfczRfummrtWy x42M3zQ1UeusCMccFSsNdAY/JwOVQm7xptowRlxusyApZCjocy0+oKstIXgxB1Irpc/V kLpMogJdTywZJ4C0D8yvM+lFoGa9EQ9dVquPievwAKvcXzqmIafoH3sxQqKJFenEAwNh CcOt5HGn/FEr337Y8KMvIxvRo2SRFohVctdDsxD+gmOEHkfL/KcdfhNMGWjf1YIZH9I5 zhYg== X-Gm-Message-State: AOAM532NmDemvKgDsvTPUg2fjpmownP1ZV2Q6h5wLQPv5lbtt1IPleC2 1DipqCFxyWs/9Wzb9S6TVOwmfj8Qgsc= X-Google-Smtp-Source: ABdhPJzghEfqgDSu9iPd9BgdRRnSqvLHwO6LTZCw0DUnUfZd5hh8KjrC+FSw9onmAbN/rJs67M2xRQ== X-Received: by 2002:a63:f108:: with SMTP id f8mr3994297pgi.96.1596651429548; Wed, 05 Aug 2020 11:17:09 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:08 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 02/21] target/alpha: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:44 -0400 Message-Id: <20200805181303.7822-3-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x531.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/alpha/helper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 55d7274d94..18169ae1c5 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -299,8 +299,12 @@ void alpha_cpu_do_interrupt(CPUState *cs) { AlphaCPU *cpu = ALPHA_CPU(cs); CPUAlphaState *env = &cpu->env; - int i = cs->exception_index; - + int i; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } + i = cs->exception_index; if (qemu_loglevel_mask(CPU_LOG_INT)) { static int count; const char *name = ""; @@ -405,6 +409,9 @@ void alpha_cpu_do_interrupt(CPUState *cs) /* Switch to PALmode. */ env->flags |= ENV_FLAG_PAL_MODE; #endif /* !USER_ONLY */ + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) @@ -412,9 +419,11 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) AlphaCPU *cpu = ALPHA_CPU(cs); CPUAlphaState *env = &cpu->env; int idx = -1; + qemu_mutex_lock_iothread(); /* We never take interrupts while in PALmode. */ if (env->flags & ENV_FLAG_PAL_MODE) { + qemu_mutex_unlock_iothread(); return false; } @@ -446,8 +455,10 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) cs->exception_index = idx; env->error_code = 0; alpha_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D052014DD for ; Wed, 5 Aug 2020 18:19:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 A90862084D for ; Wed, 5 Aug 2020 18:19:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E6OLKc6N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A90862084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O0g-0008EV-VJ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NyV-0003nU-RY for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:15 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:37183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyT-0006SL-Mr for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:15 -0400 Received: by mail-pj1-x1032.google.com with SMTP id mw10so1077769pjb.2 for ; Wed, 05 Aug 2020 11:17:13 -0700 (PDT) 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; bh=sqXifhGhW3rwKZgyTrB18rperPby0ZelegDudFYBpjk=; b=E6OLKc6NLdUktyGjvvVvhPNt5dAd9K5VQRSXtUcMKl+kVkBqql3YZXUFHfGm9CwV49 0BxYt4B/IiLbsZrGOPugnRpO1hjDejeDdnrSqt5ffAnk3LYzDAsCjMI0kqzSeaB4rV1q V67KJyzCvZrxhGdhS/HkAK8xm2GF4NPxaambIFdpjLPltmbU/0WuYQCjWBB5Zsro2YXv j5KKlZ/hQMU4OPIdjCp1fUixfigBWLyfUiS5xwlWJQEYjojhnoYDBn7rmG+BxDvtzu3i wjCD5KujPRw9tULzug78tBoyX79u5g2bBKFj9TiFlXHpb2FLTCN+Fo3Uuj3JxKPZ3jPE 4tFA== 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; bh=sqXifhGhW3rwKZgyTrB18rperPby0ZelegDudFYBpjk=; b=Vj9ReKVA8FpuEo41qtAv2FkAzQy/PcLogSgzAsN7T+i4cG5t8ATRnwWL1+Z49Llz20 PMBdK5VynYO3bbz/T7oZxC8ajxEEgGgHYxCQ1CzgGiOlNk9jC/0tTwr2vn0g3QcQ4nV2 OWDD6gHz3fNWRtYxOU6GbdX5LeoNOnD01oCyXZQPJOO5swVNrOIgwMyGeof+GehK0UC0 itbIERswEWOy0OQB1SXd7CCb0L5lwOCHDkPVUXsAZQmuVV2ZdmJMZQ2MAJUDSvI6DU11 R2Sn4LDx95fswpHj7XSmtNIcdg1ja6/9f79Pcdt+gxaE2fR0RsbrOvwbDiMEUHxjvKSt x3mg== X-Gm-Message-State: AOAM530Ocrq2zjwpuL+Kb45RWJWJs55OfVJNrNouLK2q2JRWsTbn/iSD khVQqoySwHPuxN+WMMqfOAisu+6WxY8= X-Google-Smtp-Source: ABdhPJw8Zx4kakl8T5S0K51cLOjK1lVkwtVj4Y/d4ewFjHh3mHAlt8DrxlBzFrsMeQLjxBlP30n+8Q== X-Received: by 2002:a17:90b:46d3:: with SMTP id jx19mr4582194pjb.158.1596651431914; Wed, 05 Aug 2020 11:17:11 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:11 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 03/21] target/arm: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:45 -0400 Message-Id: <20200805181303.7822-4-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1032.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 , robert.foley@linaro.org, cota@braap.org, "open list:ARM TCG CPUs" , peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/arm/cpu.c | 13 ++++++++++--- target/arm/helper.c | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 401832ea95..b8544f0f0a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -528,12 +528,17 @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { CPUClass *cc = CPU_GET_CLASS(cs); CPUARMState *env = cs->env_ptr; - uint32_t cur_el = arm_current_el(env); - bool secure = arm_is_secure(env); - uint64_t hcr_el2 = arm_hcr_el2_eff(env); + uint32_t cur_el; + bool secure; + uint64_t hcr_el2; uint32_t target_el; uint32_t excp_idx; + qemu_mutex_lock_iothread(); + cur_el = arm_current_el(env); + secure = arm_is_secure(env); + hcr_el2 = arm_hcr_el2_eff(env); + /* The prioritization of interrupts is IMPLEMENTATION DEFINED. */ if (interrupt_request & CPU_INTERRUPT_FIQ) { @@ -568,12 +573,14 @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) goto found; } } + qemu_mutex_unlock_iothread(); return false; found: cs->exception_index = excp_idx; env->exception.target_el = target_el; cc->do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } diff --git a/target/arm/helper.c b/target/arm/helper.c index c5ea2c25ea..3a22d40598 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9759,7 +9759,13 @@ void arm_cpu_do_interrupt(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; - unsigned int new_el = env->exception.target_el; + unsigned int new_el; + + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } + new_el = env->exception.target_el; assert(!arm_feature(env, ARM_FEATURE_M)); @@ -9776,6 +9782,9 @@ void arm_cpu_do_interrupt(CPUState *cs) if (arm_is_psci_call(cpu, cs->exception_index)) { arm_handle_psci_call(cpu); qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n"); + if (bql) { + qemu_mutex_unlock_iothread(); + } return; } @@ -9787,6 +9796,9 @@ void arm_cpu_do_interrupt(CPUState *cs) #ifdef CONFIG_TCG if (cs->exception_index == EXCP_SEMIHOST) { handle_semihosting(cs); + if (bql) { + qemu_mutex_unlock_iothread(); + } return; } #endif @@ -9808,6 +9820,9 @@ void arm_cpu_do_interrupt(CPUState *cs) if (!kvm_enabled()) { cpu_interrupt_request_or(cs, CPU_INTERRUPT_EXITTB); } + if (bql) { + qemu_mutex_unlock_iothread(); + } } #endif /* !CONFIG_USER_ONLY */ From patchwork Wed Aug 5 18:12:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0498E913 for ; Wed, 5 Aug 2020 18:18:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 D23E62084D for ; Wed, 5 Aug 2020 18:18:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZnxLxPvT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D23E62084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3Nzq-00064H-3V for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:18:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NyY-0003ru-36 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:18 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:45068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyW-0006Sj-4f for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:17 -0400 Received: by mail-pg1-x52e.google.com with SMTP id x6so9766927pgx.12 for ; Wed, 05 Aug 2020 11:17:15 -0700 (PDT) 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; bh=4uh7S5GyruOrvvkqIbxUUTQpHZU58D4UbwkDmUFW2EA=; b=ZnxLxPvTb1uw8jQEnCyTstBMiwJm1/3Hl5RcLjNylUbP9/6AOq2w5dNVAGoC8x+e43 AIlfcnpoi2Cv+edm2msmYD/sD8fKh1CstKZj1C/1ZxNTHuKRQyQ1AG9AMW+jHI8tLjOJ p6Iz7Dx19IeWyqCKa279WT21uor8x4+qK1j/2TkXiHwTFyM/foCngQTVm/CgOdAsbnK+ Hb/7j6fJRNtC/poUI1E8loeEGyMmjNjnAhmdXQ1bRCpieaa22khzfeZdViZKszShZDZp aut/LmiurlyLJaAMk/jwbT4nxZehEtJbl+lpHgFw61LjMG7UtqJsARtS1C2ptPxjXRb1 xhEQ== 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; bh=4uh7S5GyruOrvvkqIbxUUTQpHZU58D4UbwkDmUFW2EA=; b=gi1lkYLtIkr/mpnXruoRTO9fHniQWVgKtZM/zTxB7pieoAfEa1bUfNnLhfTfSo5sHt 2D62/C6uT27WivudjJQAeGzA6nnHy9enddFfwuZXve8p/8oh3l9q3k1UYBts0WNbe+YW SfUOfaYrIhiCngvzLpAJNrTherx0M7JKE9B5A+FkDXN5XXDY3kmbjyoYSdmx1LbY00ur X92gjC0EI/RzqCKno/Vx6bMxJdQTs6v2gnks+eyEeC0xkXeJ5Nr+j9QJsCpDk2CddhnC PdWsN03eheYGEJ/dDhDYOvv2aq8dLm+mTz8XEhA9XDmaWcwpihpS52incn+MCLJDvEHm h0DA== X-Gm-Message-State: AOAM531HpeGfWsZXZRolAFpikdaGs0Yb4rsoFFaGHq8A2/oNhbnesw5i /A8QhAPX6Jqqcj8oHuu0qTYnrPAtLVY= X-Google-Smtp-Source: ABdhPJx/ZasY6bvOdsE4vYzNmekb0VWj1du8DZv1XJhh5W87VTVb3uk4uD9sU+kPEP3G/R+7zlY9ng== X-Received: by 2002:aa7:8c19:: with SMTP id c25mr4597482pfd.17.1596651434328; Wed, 05 Aug 2020 11:17:14 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:13 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 04/21] target/avr: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:46 -0400 Message-Id: <20200805181303.7822-5-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x52e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Sarah Harris , robert.foley@linaro.org, cota@braap.org, Michael Rolnik , peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/avr/helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/target/avr/helper.c b/target/avr/helper.c index d96d14372b..f0d625c195 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -30,6 +30,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) CPUClass *cc = CPU_GET_CLASS(cs); AVRCPU *cpu = AVR_CPU(cs); CPUAVRState *env = &cpu->env; + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_RESET) { if (cpu_interrupts_enabled(env)) { @@ -53,6 +54,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) ret = true; } } + qemu_mutex_unlock_iothread(); return ret; } @@ -61,10 +63,15 @@ void avr_cpu_do_interrupt(CPUState *cs) AVRCPU *cpu = AVR_CPU(cs); CPUAVRState *env = &cpu->env; - uint32_t ret = env->pc_w; + uint32_t ret; int vector = 0; int size = avr_feature(env, AVR_FEATURE_JMP_CALL) ? 2 : 1; int base = 0; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } + ret = env->pc_w; if (cs->exception_index == EXCP_RESET) { vector = 0; @@ -87,6 +94,9 @@ void avr_cpu_do_interrupt(CPUState *cs) env->sregI = 0; /* clear Global Interrupt Flag */ cs->exception_index = -1; + if (bql) { + qemu_mutex_unlock_iothread(); + } } int avr_cpu_memory_rw_debug(CPUState *cs, vaddr addr, uint8_t *buf, From patchwork Wed Aug 5 18:12:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88E071575 for ; Wed, 5 Aug 2020 18:22:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 62EE822CAE for ; Wed, 5 Aug 2020 18:22:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ecXrb467" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62EE822CAE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O3K-0004VU-KY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:22:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nya-0003zE-Er for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:20 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:44815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3NyY-0006Sw-GA for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:20 -0400 Received: by mail-pf1-x436.google.com with SMTP id r11so15310039pfl.11 for ; Wed, 05 Aug 2020 11:17:18 -0700 (PDT) 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; bh=MJQQ/dt5YPVkuurfAkJuoHtRneXdeiakI4OjTjMGNhA=; b=ecXrb467asYl7YNp/vXs2aS0/5T8I2Ufg8BsI7f0Iu/Wml6ucV0bCY1gRFZryfvNXC fHFnJJZLoEumsYXCUB4GVPM6AWYKybYAf0QMT3BBs3l/BzKaiCPepUGMCghM1kaCeLHG LW5TPgjtunBMCgwE1CT0Jxk7XttdbIYYbcpDUBow+oNQv/cjCW62+hkGH4gXsHnIFQ7U mno2fSJ1KqlM8w079kPyFNzMnKXIk5QMLTLl5mrzPZ5xSoLuuMD4Tkij3L/2EKgC/a0O G8i8ijbCCBtodppYNmPQOp9ae768KAo507AzP9SSItMF3ckURhzj0hz520bka3ND5Y3k oaWw== 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; bh=MJQQ/dt5YPVkuurfAkJuoHtRneXdeiakI4OjTjMGNhA=; b=TF6QDyqN3Wb5dgqz+KREPzUIV08zjTavJRZUNC1LmIEHBWKDGwXfg5Ngi9JhAat3kk OKjJ2UC4JhZyHKKoVdTDzSnHj0byKzUZvVt+bziHUAZw+53L+OHjYlacfnCLTXKOlGDp YRTrGFpEiBxc3Ykbaxv2X2o4Fh6Lg81VYwxInv3Al2J+vG6yu2+m64gVR2ja0jJ2Gl/L LhDQV0KEHCJCxSGftyAPXxjFMp9R2gVDARnOVQSOsPgLfC9+Jjl/ebO9VIjZh0HHyFD1 txgnbBjJjfHLK9BXR/lyBls1WoON9Xd6fR1iR/zQNy5cz6srh7G4xXUahWTaAfyE2fiY WmLg== X-Gm-Message-State: AOAM532lQF8yPHkL2++hNPb/WP6GyqHsV0bQUYIEDtU0aSe5WUBr3wh0 E0ilfgLaUezuWXDUFyuISMxENZ963/s= X-Google-Smtp-Source: ABdhPJxdUuFzb9zIkBqwhnwHnPROq9eLL1vi5jEf6DRKhkiPvrj7S4oQQpbTORBBiiVdWZ9z965Ttg== X-Received: by 2002:aa7:9a4c:: with SMTP id x12mr4624405pfj.307.1596651436669; Wed, 05 Aug 2020 11:17:16 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:15 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 05/21] target/cris: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:47 -0400 Message-Id: <20200805181303.7822-6-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x436.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, peter.puhov@linaro.org, cota@braap.org, pbonzini@redhat.com, "Edgar E. Iglesias" , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/cris/helper.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/target/cris/helper.c b/target/cris/helper.c index 67946d9246..22aecde0f5 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -45,8 +45,10 @@ void cris_cpu_do_interrupt(CPUState *cs) CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = &cpu->env; + qemu_mutex_lock_iothread(); cs->exception_index = -1; env->pregs[PR_ERP] = env->pc; + qemu_mutex_unlock_iothread(); } void crisv10_cpu_do_interrupt(CPUState *cs) @@ -128,6 +130,10 @@ void crisv10_cpu_do_interrupt(CPUState *cs) CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = &cpu->env; int ex_vec = -1; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } D_LOG("exception index=%d interrupt_req=%d\n", cs->exception_index, @@ -183,6 +189,9 @@ void crisv10_cpu_do_interrupt(CPUState *cs) env->pregs[PR_CCS], env->pregs[PR_PID], env->pregs[PR_ERP]); + if (bql) { + qemu_mutex_unlock_iothread(); + } } void cris_cpu_do_interrupt(CPUState *cs) @@ -190,6 +199,10 @@ void cris_cpu_do_interrupt(CPUState *cs) CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = &cpu->env; int ex_vec = -1; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } D_LOG("exception index=%d interrupt_req=%d\n", cs->exception_index, @@ -265,6 +278,9 @@ void cris_cpu_do_interrupt(CPUState *cs) env->pregs[PR_CCS], env->pregs[PR_PID], env->pregs[PR_ERP]); + if (bql) { + qemu_mutex_unlock_iothread(); + } } hwaddr cris_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) @@ -294,6 +310,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request) CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = &cpu->env; bool ret = false; + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD && (env->pregs[PR_CCS] & I_FLAG) @@ -315,6 +332,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request) ret = true; } } + qemu_mutex_unlock_iothread(); return ret; } From patchwork Wed Aug 5 18:12:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7DFD14B7 for ; Wed, 5 Aug 2020 18:20:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 BF130206A2 for ; Wed, 5 Aug 2020 18:20:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cIZjaXa9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF130206A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O1C-0000Ty-0r for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:20:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyc-00045M-U8 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:22 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:45788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nya-0006T5-Qg for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:22 -0400 Received: by mail-pf1-x434.google.com with SMTP id f193so12811385pfa.12 for ; Wed, 05 Aug 2020 11:17:20 -0700 (PDT) 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; bh=aWTfVEr9viFrQ6JCbNZOP6prnRfgRwiZmrjVsEZMWCQ=; b=cIZjaXa9hCmfhlDZimPZ7RTB0p8QjdV+aDkQ3YeAXdeQA1ABzzYQLs0zaTRszYaR8m /wtrkc1vQCGe3N/Paa5axVhKP4MCoAKnZgltYzS/cFw986qNp91/lHYc0bO6QgRauwEh grjmKawATF0BOtBwvIwNK6TtyuO4w/QNfMiqLvj0Szky98MJRKC5wIaO3k9SsXTx4cyo 9qIfIlvitWZXDazwY0jHL6lXBygihw5WxhimwIPDiipJIyF2hK9KIWnlNsTp/hFlmB2p Jn9sNFHcgTK7WtkDMdKyjKFdsEMXdFl8V3/jxksA/ta/Ugf2ubdCngi3B1ymhGZLm6Wh KPig== 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; bh=aWTfVEr9viFrQ6JCbNZOP6prnRfgRwiZmrjVsEZMWCQ=; b=NLfUdGk1O23U5TYbi46E59P69Mj2fHmNOJ+nsduTwnrSyxV8ogmWmfdTogXWIo0aLr yeu9JkVX7pUpB5uGV0dgxldxuWZqLoG7XkLOk20bkLUzqI1pG65SwiBNxvHYO4iHefwL VxuJ2MbNDzn+Nd34u2bvEUMDG52KsWZaMNnyIl8nMm5Ap/pCdLIJaKb3BPBYtm6UUQtS zDc0D/xEte6DDrT256mcaPMVovmoUXMiutHZoSImA/DjwnvIqYuQGKkIvzkT77HnRJOB liuSwEG3MWSPGXGKAkA4qIPG7IjFQBD6kYKEIthaCbYi37+FG8BD6KS8+1bJNym/ZrRq RohQ== X-Gm-Message-State: AOAM532TF1CJ80j9NqkKx5w0kbVtrqod/NrOxloxaEm000jMiL1gdbDR P8hVgkdBg/F4hnhesDCH79YGHO0Tfjw= X-Google-Smtp-Source: ABdhPJxrozRL954sZkjObw8MLIG8suUN+0VxlDWhcSrtjgZUynlTnFWQ49c8jOF/fLPydX5ssZCkug== X-Received: by 2002:a63:d446:: with SMTP id i6mr3893370pgj.438.1596651439003; Wed, 05 Aug 2020 11:17:19 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:18 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 06/21] target/hppa: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:48 -0400 Message-Id: <20200805181303.7822-7-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/hppa/int_helper.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 462747baf8..eda40bc5d9 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -94,12 +94,20 @@ void hppa_cpu_do_interrupt(CPUState *cs) { HPPACPU *cpu = HPPA_CPU(cs); CPUHPPAState *env = &cpu->env; - int i = cs->exception_index; - target_ureg iaoq_f = env->iaoq_f; - target_ureg iaoq_b = env->iaoq_b; - uint64_t iasq_f = env->iasq_f; - uint64_t iasq_b = env->iasq_b; - + int i; + target_ureg iaoq_f; + target_ureg iaoq_b; + uint64_t iasq_f; + uint64_t iasq_b; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } + i = cs->exception_index; + iaoq_f = env->iaoq_f; + iaoq_b = env->iaoq_b; + iasq_f = env->iasq_f; + iasq_b = env->iasq_b; #ifndef CONFIG_USER_ONLY target_ureg old_psw; @@ -244,6 +252,9 @@ void hppa_cpu_do_interrupt(CPUState *cs) env->cr[CR_IOR])); } cs->exception_index = -1; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request) @@ -251,6 +262,7 @@ bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request) #ifndef CONFIG_USER_ONLY HPPACPU *cpu = HPPA_CPU(cs); CPUHPPAState *env = &cpu->env; + qemu_mutex_lock_iothread(); /* If interrupts are requested and enabled, raise them. */ if ((env->psw & PSW_I) && (interrupt_request & CPU_INTERRUPT_HARD)) { @@ -258,6 +270,7 @@ bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request) hppa_cpu_do_interrupt(cs); return true; } + qemu_mutex_unlock_iothread(); #endif return false; } From patchwork Wed Aug 5 18:12:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A15B014B7 for ; Wed, 5 Aug 2020 18:24:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 7A71C22CA0 for ; Wed, 5 Aug 2020 18:24:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SQMq/9we" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A71C22CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O5D-0007yy-OW for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:24:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyf-0004AC-1Q for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:25 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyd-0006TM-1L for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:24 -0400 Received: by mail-pl1-x644.google.com with SMTP id w19so12780409plq.3 for ; Wed, 05 Aug 2020 11:17:22 -0700 (PDT) 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; bh=7mh5d9hE+bxonA2bwtaQKP+LmgXiTqiWTHlCBZ977OU=; b=SQMq/9we4q+19/caWZFngtndjaN0uOziOTM4wIAbC/vnTqznC1Y3Gu/CGYE8A0GMqr NHEEPK+UnbNGEJgzFYXzCrrjrNtRXcTU0vkY4voIgj2BZMWKQtOXoTdu5pKF4l4g4bmH KMg1V+4sK8VRBcK+t5+vPaT6k0Ym2u2t2H+8/Cazx2c65T+xY1z1YL2uX/UpJBzBlW4i mqeUoSg3McCf0BCSUEfRnH7FBGyVwLvtFoqQ9REFw4seq6WdwTyphGQwsWQzdXETSUwf wfkzY9cKaTqYUshbYV5SjqSRtI5vKd57gkXacfTtyqxX7qzhcstDLr/qy9moLXrekVZq Nuww== 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; bh=7mh5d9hE+bxonA2bwtaQKP+LmgXiTqiWTHlCBZ977OU=; b=JZUFpftpqNn1Kqn+4XHizndbv8SW8EqCsHJbgWkJzpz/t7TcBnxn9h4sLU/nYmjOXn RBGmU2cK+uyGvkTbdqnJpSH26tMAxBKz3ALhh+DbtOissa9lEaHqgR+DNl6Au0wTk3tf 8nY1YMu3g6gDhIKFHzEPEfcPufoqhlXPVWPumYbGgj2fVF0z3+gwipW3l1WaGt8tHA3B bQZI0+2z2KMxZN1kCBc5kR8bXJVFu1yq7p9n9kepRa9nOzSKXMHxNUtWx6xxgqJzGhyx ro1zt4Kcg+o8lSl+0K/maTcWuVaVQjlTxhkQhMRqG7Oe0/H0ilNipXm9T6pKcvHU+Jvo 7hag== X-Gm-Message-State: AOAM5336hSYjEabgPY6YCTsRl5jwdbPmwrsLlmZ7yLf3Mos8N+g66HUP +wL1KL5rVNMawROFri4I1Es/E/0IpFk= X-Google-Smtp-Source: ABdhPJz/wt6vOGXTf2OfCyYAFBAwV+q5kpCK3msmxcBKx/QaGLSXMKiqIAswp3UYnOfTOjM/uRc0Zw== X-Received: by 2002:a17:90a:5a01:: with SMTP id b1mr4072906pjd.27.1596651441319; Wed, 05 Aug 2020 11:17:21 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:20 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 07/21] target/i386: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:49 -0400 Message-Id: <20200805181303.7822-8-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Eduardo Habkost , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/i386/seg_helper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c index 818f65f35f..114d4a0d24 100644 --- a/target/i386/seg_helper.c +++ b/target/i386/seg_helper.c @@ -1284,7 +1284,7 @@ void x86_cpu_do_interrupt(CPUState *cs) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; - + qemu_mutex_lock_iothread(); #if defined(CONFIG_USER_ONLY) /* if user mode only, we simulate a fake exception which will be handled outside the cpu execution @@ -1308,6 +1308,7 @@ void x86_cpu_do_interrupt(CPUState *cs) env->old_exception = -1; } #endif + qemu_mutex_unlock_iothread(); } void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw) @@ -1320,9 +1321,10 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; int intno; - + qemu_mutex_lock_iothread(); interrupt_request = x86_cpu_pending_interrupt(cs, interrupt_request); if (!interrupt_request) { + qemu_mutex_unlock_iothread(); return false; } @@ -1377,6 +1379,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request) } /* Ensure that no TB jump will be modified as the program flow was changed. */ + qemu_mutex_unlock_iothread(); return true; } From patchwork Wed Aug 5 18:12:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8B481575 for ; Wed, 5 Aug 2020 18:26:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 911AD22D08 for ; Wed, 5 Aug 2020 18:26:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kXpbP+C2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 911AD22D08 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O7E-0002ip-JD for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyh-0004F7-39 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:27 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyf-0006TU-2K for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:26 -0400 Received: by mail-pl1-x644.google.com with SMTP id r4so15134267pls.2 for ; Wed, 05 Aug 2020 11:17:24 -0700 (PDT) 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; bh=sPSOE7FlbJqSNOCq29FKQeTA9v1eH7Mn/6Yq8WOQ91Q=; b=kXpbP+C2n9auaXiYPp+Eepc+/rRmw8U+C30wKtE2ujwOqJQ42A5YToUA29b835eoOm NlCqlIgtLVJ9DkqYSuGUaUlQfKH8pCwTkvKrRX2CvNXpH26YOsMSDtzvJ4f+rdthJkeQ w91ZUKT0reTrfrDWByWFl/Fmgu+xGROindsnV1xOI1B/aIWeXGwU5L/kMGEyd7lv/jCl TAyRCW99BtjAWsMnEoavx3aoHZfPvBttjDEc34wa5nR+cbpB4Drxv+2uJjGVhc64cXNr Q0v587VqLJj8Zk5Lo203XbczOIUpjEruNmb97Nwxb+jeHXjvhBfg/YA1XKwXiLMMtJ7D Lf9w== 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; bh=sPSOE7FlbJqSNOCq29FKQeTA9v1eH7Mn/6Yq8WOQ91Q=; b=sg0DwxdiQLWqyR1LF5A4MNttmeXVP/tlcNHNsQJI1MrXxjTcM0sAQoKY22Ze9qgSUz xOPD3PuY1xrkEWHz1p5ciw/C66repThQ5miwXjRpbvK6gRYdSZmHyWUhIazsj7TBJFnA yTuTJ2elZfwu5Rb8iw9FQsvsixc7kwFU5APCKATiVbKMsBSiVOoeCRoKxRHS4562me3G 97A+mVTV2dqOle/k8VuWqeNnzLGtG3+GKbjVyfaY30aIKTmSLsmev0KF9yjnoPNetPbg lwkJuP6s8g/RlLJOCH1HRpebXnmG5nHpH5hWWBijacfsfE3Krq5306ET9jPzl9ksBAgy qQFQ== X-Gm-Message-State: AOAM533ox/ymzTXZQdwsYzvjfTYDFx1VHpqLsPKgXdVNhbrEdsn+0iC0 HD64c7c+zEPuQLMwuqpn8klhVy52xA4= X-Google-Smtp-Source: ABdhPJw57bBafTcrbeEn9KTju0Fby9+jOLCrQjaT0w6KEmbO2yygSwn+uonyHxDc68CyPrMYV9U/Jw== X-Received: by 2002:a17:902:a607:: with SMTP id u7mr4360104plq.45.1596651443512; Wed, 05 Aug 2020 11:17:23 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:22 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 08/21] target/lm32: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:50 -0400 Message-Id: <20200805181303.7822-9-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Michael Walle , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/lm32/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/lm32/helper.c b/target/lm32/helper.c index 1130fc8884..4439b06ecc 100644 --- a/target/lm32/helper.c +++ b/target/lm32/helper.c @@ -152,6 +152,10 @@ void lm32_cpu_do_interrupt(CPUState *cs) { LM32CPU *cpu = LM32_CPU(cs); CPULM32State *env = &cpu->env; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } qemu_log_mask(CPU_LOG_INT, "exception at pc=%x type=%x\n", env->pc, cs->exception_index); @@ -196,18 +200,24 @@ void lm32_cpu_do_interrupt(CPUState *cs) cs->exception_index); break; } + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool lm32_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { LM32CPU *cpu = LM32_CPU(cs); CPULM32State *env = &cpu->env; + qemu_mutex_lock_iothread(); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->ie & IE_IE)) { cs->exception_index = EXCP_IRQ; lm32_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76A9F913 for ; Wed, 5 Aug 2020 18:21:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 5081022CA0 for ; Wed, 5 Aug 2020 18:21:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pgFeFCV2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5081022CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O34-0003vQ-Hf for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:21:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyj-0004KP-Fn for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:29 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:33108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyh-0006Tj-JI for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:29 -0400 Received: by mail-pl1-x642.google.com with SMTP id g19so13194188plq.0 for ; Wed, 05 Aug 2020 11:17:27 -0700 (PDT) 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; bh=sAMCBrWOlvhWHRQfoPG7nat7D/DsWHPnezgCzgjj800=; b=pgFeFCV28gv4EmomjDuouj08WrzlGGVyl4HrPVq1A3OBVWQzCKx+H0SQ2lKMKrK4qB iYDKiZEQZyN+dAjIVCioY7q3XGkOccA7zxrTa6Ja65AOxlrmsc5OL/tjdRMEp9v3GVT0 WuSLnKaAEzF08yAqcEH4H9lnkDmoEOznYUMkkpbvBphq/d+/Rs1s55MVY8dea7f7GgoB Fmr9G3RH4BoP9n2JxESNitGRDzFpmBz1kktdOYn+r/Q6X1ycGAnwoMrKmXJdPvGhx+FD /SqQeV2GwaYLI6bDeG6luXUT56l7fT4xHIv0eTPhUr8WPaW4+iY2brd7k0A1RGXQ+6ee ViGA== 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; bh=sAMCBrWOlvhWHRQfoPG7nat7D/DsWHPnezgCzgjj800=; b=mQBpVQu6GB491I14rxRgY7M0kYi3IlbnNGy8s7/Fom/lHfB7Et9+Rl48/sQLvrgMIj YSYEF5yt1xSxG2bgt3B+DsmUyqkmuVwShuu0XIBLHiBDSLItV3z36dxOboUoh9xydBQl ZMq8/IsXcO+UtSsu6CQ7cZpRIiqerEqRVBZHjojv+BnzxKcYM2+qv1hr+ZUm74sM/Ho0 JtkTgENo/EvzZBMkHFGHEveUJL4l/30red/hnkYrbO+PcUcGCU62hctrfdmaCIHOsUVr YTXJj8paEC+vDHiYgnImUcnkgRVdOaHB4GiWdC29ZnQIxLwv8FhaIbbTDql1uyX9jzu3 JRvg== X-Gm-Message-State: AOAM532wOidjrJM3tV1erUAHb6dovTY9kyRLn3QYiqoSB9ZIP/24caol QTtZwVarLpy//viGcBESynvdUoj00s8= X-Google-Smtp-Source: ABdhPJzDneRVJGQlpi0AXr3Q4Oqc1LhHMlOzGzmZ8ep7wXdXwe09mymA12VoEfGNS62OZGhR6C8+vg== X-Received: by 2002:a17:902:7d84:: with SMTP id a4mr4286651plm.44.1596651445773; Wed, 05 Aug 2020 11:17:25 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:25 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 09/21] target/m68k: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:51 -0400 Message-Id: <20200805181303.7822-10-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Laurent Vivier , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/m68k/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 4a032a150e..0c3333476a 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -448,7 +448,9 @@ void m68k_cpu_do_interrupt(CPUState *cs) M68kCPU *cpu = M68K_CPU(cs); CPUM68KState *env = &cpu->env; + qemu_mutex_lock_iothread(); do_interrupt_all(env, 0); + qemu_mutex_unlock_iothread(); } static inline void do_interrupt_m68k_hardirq(CPUM68KState *env) @@ -508,6 +510,7 @@ bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { M68kCPU *cpu = M68K_CPU(cs); CPUM68KState *env = &cpu->env; + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD && ((env->sr & SR_I) >> SR_I_SHIFT) < env->pending_level) { @@ -519,8 +522,10 @@ bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request) */ cs->exception_index = env->pending_vector; do_interrupt_m68k_hardirq(env); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87FAC14DD for ; Wed, 5 Aug 2020 18:19:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 613E52084D for ; Wed, 5 Aug 2020 18:19:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sowj/PvI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 613E52084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O18-0000KL-KZ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:19:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nym-0004PB-Ep for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:32 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:39054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyj-0006Tx-Qh for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:32 -0400 Received: by mail-pj1-x1036.google.com with SMTP id f9so4779659pju.4 for ; Wed, 05 Aug 2020 11:17:29 -0700 (PDT) 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; bh=AeDpfxqkdAEXeD0Us9Svn7h86jElbTJX/muq5WTwNbc=; b=sowj/PvItMmu8NBwvfGGeqmrW1OX1jqRjIyWgAzoKIwV8FNfxYd9wnclVR70+vRkRS Jon4BlDzbt/dVJrbMcTyBJM/GxzmidudqoS8DBKBj2D9S6LhTPZGFCUogaJ4DZH5xhFf aj4lbeqK3fz6cN5ycfFqTveISpgW1AldVb/uiWyO09TA3TP2HKOsCApmdKKEtHLSKXW8 iVBqwbgp2ZbD5hFrxwyvq/n2/uqhrcT7xtsyE4mgXX2bZSa4sbpUuJVyP/61w7oKwKlU INCQMjkh5+/HLoqEGQRtlRnpaOdRcdFLWrIKzzlihL5KoJ0hJaGH1+9IBlJtObXZNI/7 S0IA== 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; bh=AeDpfxqkdAEXeD0Us9Svn7h86jElbTJX/muq5WTwNbc=; b=gqeNYMF7zIpzZ2AiRRyywkjpWUzzF4+2wVOIN2wQN7n994QHOFMSb9aOrIx6QZswmW owxKqd6KIjr/TaVyDgp9Uu27yAESwRTrqpvEM8ONmfJFuVg90gmr0GTQDsTW/w6SiZux 7ZhIo+yb1PbAQgyr59sntIVcob1FjRYWTOJx78jiBv+Re9knTEK4mfyEcQGHH8dBCyDc iiOqfbzmQtrrPBXzo6GWOHPsv9/Nn/WHocLrdP/ymFaoJE1QFiPYMaYloUYp5p1nRMg8 ceEEm7OMTc/Fs1qN3dXo084BAKJC4827fhyFuu01u7jVfSEUnAysJwL86Gc2+ul1Uub5 0/OQ== X-Gm-Message-State: AOAM5312AF1EGsRX0ZRCHjtIj5wQEbNswvVfMYT1SgdVGyV2bn0MeCim OltNB0xPTOJCXKJ6ZBWahtfbgCPrztY= X-Google-Smtp-Source: ABdhPJwrPV0yaoOViRhr+N22GpjgeRHLeBaXFKz2BBst8GXbBUNPCJ1Mx0DgOJbpq3oxBIeKtTIu6A== X-Received: by 2002:a17:902:40a:: with SMTP id 10mr4238883ple.180.1596651448072; Wed, 05 Aug 2020 11:17:28 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:27 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 10/21] target/microblaze: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:52 -0400 Message-Id: <20200805181303.7822-11-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1036.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, peter.puhov@linaro.org, cota@braap.org, pbonzini@redhat.com, "Edgar E. Iglesias" , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/microblaze/helper.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index ab2ceeb055..ae8ff2bea4 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -32,10 +32,17 @@ void mb_cpu_do_interrupt(CPUState *cs) { MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); CPUMBState *env = &cpu->env; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } cs->exception_index = -1; env->res_addr = RES_ADDR_NONE; env->regs[14] = env->sregs[SR_PC]; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, @@ -113,6 +120,10 @@ void mb_cpu_do_interrupt(CPUState *cs) MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); CPUMBState *env = &cpu->env; uint32_t t; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } /* IMM flag cannot propagate across a branch and into the dslot. */ assert(!((env->iflags & D_FLAG) && (env->iflags & IMM_FLAG))); @@ -123,6 +134,9 @@ void mb_cpu_do_interrupt(CPUState *cs) case EXCP_HW_EXCP: if (!(env->pvr.regs[0] & PVR0_USE_EXC_MASK)) { qemu_log_mask(LOG_GUEST_ERROR, "Exception raised on system without exceptions!\n"); + if (bql) { + qemu_mutex_unlock_iothread(); + } return; } @@ -262,6 +276,9 @@ void mb_cpu_do_interrupt(CPUState *cs) cs->exception_index); break; } + if (bql) { + qemu_mutex_unlock_iothread(); + } } hwaddr mb_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) @@ -291,6 +308,7 @@ bool mb_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); CPUMBState *env = &cpu->env; + qemu_mutex_lock_iothread(); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->sregs[SR_MSR] & MSR_IE) @@ -298,7 +316,9 @@ bool mb_cpu_exec_interrupt(CPUState *cs, int interrupt_request) && !(env->iflags & (D_FLAG | IMM_FLAG))) { cs->exception_index = EXCP_IRQ; mb_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10983913 for ; Wed, 5 Aug 2020 18:21:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 DCAFD22CA0 for ; Wed, 5 Aug 2020 18:21:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xTjpRxu7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCAFD22CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O32-0003rW-19 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:21:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyo-0004Qw-9S for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:34 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:51543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nym-0006U5-91 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:33 -0400 Received: by mail-pj1-x102d.google.com with SMTP id c6so5024195pje.1 for ; Wed, 05 Aug 2020 11:17:31 -0700 (PDT) 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; bh=TQf+kUTKaJ/snZqXoVWLiq9osz3e4ZNpxcetm6dWt8I=; b=xTjpRxu7HKdV2Bz9nOANpvgfUs9av4+RyFPXe/KiNgkf7fgIrqz9/1F52zNNifoO5f 82J3UKbwrNjZUAa3+jG7R6TK2xl1OPijHaBNqyZGNb+oBoZQMR+rSVNYhGasTOkAmB6h UZcx2UZJWcXND+tXFwFmlkOjU4VfohT24F+Vs4MmWuZFq34ldRn/JSjO+zAvcKl83rCm u99vaeu/IrDe2qTMOyIGKnneHTo25v/7F2af1L/V15i5RVW4hjMyHosssy4LNpPFuvcx 0lbHALvPRUHLpSotwcs5eDXV3pPmC8mYunvhI1d+RUIFmxP8eZQJ91cSreFrZ7xiJPJ4 fX1A== 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; bh=TQf+kUTKaJ/snZqXoVWLiq9osz3e4ZNpxcetm6dWt8I=; b=MWosaawdH3GfZ84Ma3jf4+IBirjZ0itduZq8qx6J+FMP30mim8PAQv6D93MgvBLubd zoQtnY6KVW85Ip1gAlR82Kf6SWQA6YQQtqvsR26gU3emEON5Xw/VOsQspgtkLNK88Pjr oF4A6NkNx28FpXLliWbhHJJt849VkFcXD9yqV7d5ynouJGE9hE0NYSs4CXo9F6c736oU pF5VFx8ZT6+ZyidauIeqkIKZfpP+fh+xVBwXiJ1zMaYFM9W4NPS1yva7J3eqv20dUl9w VLWSFInS+xOCpIU2XKR/KcMfHLVKKQp0nMkF3vYUgH/JzU4B40tU+cwPjuc9EQ5FzPTR FotA== X-Gm-Message-State: AOAM531Zn7+QxSpB63DTYrG+KUI5Yew2ivskWzMEGM78HgE/EPgrA6KF AwiLs+RuMiuGwQ8v9ld6KOB3ovb8uXQ= X-Google-Smtp-Source: ABdhPJzdfsJfzIWCvPO81S1GWX9CY4ctiQoHANbdnrz/V3t2SAGln5dbhnt7dYemgn/sw22nZid5gw== X-Received: by 2002:a17:90a:3488:: with SMTP id p8mr4695488pjb.211.1596651450623; Wed, 05 Aug 2020 11:17:30 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:29 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 11/21] target/mips: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:53 -0400 Message-Id: <20200805181303.7822-12-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x102d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Aleksandar Rikalo , robert.foley@linaro.org, Aleksandar Markovic , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/mips/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/mips/helper.c b/target/mips/helper.c index afd78b1990..6595d18702 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -1085,6 +1085,10 @@ static inline void set_badinstr_registers(CPUMIPSState *env) void mips_cpu_do_interrupt(CPUState *cs) { + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } #if !defined(CONFIG_USER_ONLY) MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; @@ -1396,10 +1400,14 @@ void mips_cpu_do_interrupt(CPUState *cs) } #endif cs->exception_index = EXCP_NONE; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool mips_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; @@ -1410,9 +1418,11 @@ bool mips_cpu_exec_interrupt(CPUState *cs, int interrupt_request) cs->exception_index = EXCP_EXT_INTERRUPT; env->error_code = 0; mips_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9812614B7 for ; Wed, 5 Aug 2020 18:20:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 7191C22CA1 for ; Wed, 5 Aug 2020 18:20:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="v+BBqbP/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7191C22CA1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O1W-00011J-LV for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:20:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyr-0004Xl-7W for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:37 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:38336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyo-0006UG-Pf for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:36 -0400 Received: by mail-pl1-x634.google.com with SMTP id t11so5929693plr.5 for ; Wed, 05 Aug 2020 11:17:34 -0700 (PDT) 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; bh=cutmHWKlIHi21iMgNNh40sQAOAMRR/Z5ERVDwteMD+o=; b=v+BBqbP/zW2O/aI07r/sbKM8b2Sp0TgB9piY0V+HeJHhVB+wiSGb/WRhBgFldUSd/a EzSPZ4gGRNoa932xDw9+piLUL06pF531fpIDQjcwibiCf5kitz+az5+qGlEfENoeXSRA XycLxXEOiipVissdBxlfDy42+Hpp6yNuC9dvhImwAlsv6yyEzSmZrz4g/Tt8E8LJx764 Nub09SWSChP2uf2RGNEIyQawZOTWr3rTymr/E1Fc0vqvimGwDgS82qN5M+8w4Ln5Ezcv 1hXKLnRB/SNOlFuew7+kYwClUkuHds//regjqEzuH6Yucl3voHWOb8nnWp/usgdOsyaQ VSOA== 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; bh=cutmHWKlIHi21iMgNNh40sQAOAMRR/Z5ERVDwteMD+o=; b=tOQVIXrgjgKqxXVL9UR7Z48x3H/AnYo8Ix486K8QuWCPrL3TuQKlYFiEOwXOVfzuXM NzYTdfWfUuKBFVcebvc5LgkTDWWvplEMHSRr9QrlP1uBnP3D/Xiwej13G97uPMOCdpAM lT13L1BTHmCtfrIh7jDRNwDGUQPglGuooWMttUSpA4nUxyRJ0KVZHZaOaH4uqv2bNwgq /z8wYxBoGoqG7kx5SmdZTLv7KXtnmr0Qwby8EOzfyC7FUVwSRT0A2+vVAzkYsu9RvehS R9R90YWK9pawwhzC4f/4kJdOxijz78OWhIn7VRJH70SnZ52wMD6aMhoJQC87m1hIva8f 2PmQ== X-Gm-Message-State: AOAM531msnf26qpcZDa4kO7QwZnq9gnqiPP/tlXHUPPb98odf6BTGuGD QcqUnjMnLAPFEWF1XZJ+3TVa4YjMq4s= X-Google-Smtp-Source: ABdhPJw7gffbpSB5icFictoWkKXrDNV73GWso+3knCJVPqKcQQYhfw39NpKw0F0VHa5PCux6kFWbAQ== X-Received: by 2002:a17:90b:19d2:: with SMTP id nm18mr4588554pjb.124.1596651453081; Wed, 05 Aug 2020 11:17:33 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:32 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 12/21] target/nios2: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:54 -0400 Message-Id: <20200805181303.7822-13-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x634.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Marek Vasut , robert.foley@linaro.org, Chris Wulff , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/nios2/cpu.c | 3 +++ target/nios2/helper.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index fe5fd9adfd..fd05406eac 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -102,13 +102,16 @@ static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; + qemu_mutex_lock_iothread(); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->regs[CR_STATUS] & CR_STATUS_PIE)) { cs->exception_index = EXCP_IRQ; nios2_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 57c97bde3c..46d53551d4 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -52,7 +52,10 @@ void nios2_cpu_do_interrupt(CPUState *cs) { Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; - + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } switch (cs->exception_index) { case EXCP_IRQ: assert(env->regs[CR_STATUS] & CR_STATUS_PIE); @@ -198,6 +201,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) cs->exception_index); break; } + if (bql) { + qemu_mutex_unlock_iothread(); + } } hwaddr nios2_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) From patchwork Wed Aug 5 18:12:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 372F214B7 for ; Wed, 5 Aug 2020 18:23:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 0F73722CA0 for ; Wed, 5 Aug 2020 18:23:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PZrgCSmK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F73722CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O4s-0007Jc-Ag for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:23:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyu-0004bc-Dy for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:41 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:33810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyq-0006UW-W0 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:39 -0400 Received: by mail-pg1-x532.google.com with SMTP id t6so24960072pgq.1 for ; Wed, 05 Aug 2020 11:17:36 -0700 (PDT) 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; bh=JEsnnFYRnVZaq0i2DwuNSLaqhNKEKeJEaJl1TkjXWDY=; b=PZrgCSmKb1oY1ZGeU/YExUk6KMJyebctyIkNwjN8iZl+GCeVQzj9zMnUA5xHiGm44R oui3/hc1hBukPsrDR2dKR4vOmAOq3rpMj1SyMSzH3ct6FJ8l6MqkUmygnWof8kI9k6FT 6wyxw/5G60uhr5zk4t5833ZbTvYPclMttmEcwDhNvHamf/QKHRgiIJqf3lrPtKGyTByT 0CQy5Nf+Xdm/MsbGmpnJLgV4BKBgimM9lgKLlWIXf32OCzIHzxsIfmbBcKTjc8483Igt 9rYH5KodW3ZHTfqgbc6wVmUUMmo7yrk/sgTZDw4OxvbeeojikP3ZKvphGx7ztAGWH8Yw l9lQ== 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; bh=JEsnnFYRnVZaq0i2DwuNSLaqhNKEKeJEaJl1TkjXWDY=; b=tYmkpx7ZHhVJIY9omTY63KuiCLvR4reS2xyMbYwccCgiCDmYzsuWv69fWPYHBnqDS/ t52uL41N6TnYxtdkSqzrSrlhmvf+wIiKpXmUhLD1tj/CczhL4DWdPKX9dm4W+WeEWyf0 BhJxesenvK4D0fAeTCuH+ItrqDVEWLuawJ6AMs7Fjs/dQK2jK5bDzA9WnOZjiXQ07LJz EWDqPI6JGYwqr6w6kFTghXZ/VSOH7OhcBGSGvC/aQcTR2slas9458LvyJy2yzQUTgEF+ tMzFs2c/yJD2sMZS0ShE+H1Xam9pM4UMX3ii8N6H1Z3vYOA4yghOkmIkFDvNQQrra/R7 8QFg== X-Gm-Message-State: AOAM532Eq0PXyP6mBX4OdBVN2ZkQVkvwM9Bjl2RJ2hSX6sX1xsZeRe/K a8XKIhjR7nnDF49hwTwqLpHT7Vm/LYE= X-Google-Smtp-Source: ABdhPJzZ586Vu9XBmAKRIdoBA3GDtYL3zEBxDz6xsJL8sUEkEW3ojvVVMfcSa+Gsf8ItsYdDP+fkOw== X-Received: by 2002:a63:5012:: with SMTP id e18mr4028460pgb.169.1596651455325; Wed, 05 Aug 2020 11:17:35 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:34 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 13/21] target/openrisc: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:55 -0400 Message-Id: <20200805181303.7822-14-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x532.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, Stafford Horne , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/openrisc/interrupt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 3eab771dcd..361f242954 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -28,6 +28,10 @@ void openrisc_cpu_do_interrupt(CPUState *cs) { + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = OPENRISC_CPU(cs); CPUOpenRISCState *env = &cpu->env; @@ -99,6 +103,9 @@ void openrisc_cpu_do_interrupt(CPUState *cs) #endif cs->exception_index = -1; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) @@ -106,6 +113,7 @@ bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) OpenRISCCPU *cpu = OPENRISC_CPU(cs); CPUOpenRISCState *env = &cpu->env; int idx = -1; + qemu_mutex_lock_iothread(); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->sr & SR_IEE)) { idx = EXCP_INT; @@ -116,7 +124,9 @@ bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) if (idx >= 0) { cs->exception_index = idx; openrisc_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAEBE913 for ; Wed, 5 Aug 2020 18:26:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 81EEB22CBB for ; Wed, 5 Aug 2020 18:26:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Tds7I/U9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81EEB22CBB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O6x-0002Dd-I6 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:25:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyv-0004cZ-Md for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:42 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:42201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyt-0006Us-OH for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:41 -0400 Received: by mail-pg1-x52e.google.com with SMTP id j21so6223070pgi.9 for ; Wed, 05 Aug 2020 11:17:38 -0700 (PDT) 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; bh=cGAJoan4B9O593ZoXcT9RzOP5KLkia4jZDLI7E+9tcU=; b=Tds7I/U9g+SuWu3CENUS8yD1R6zMlB5mTn7dhl0J0a5fepdDTWILnXeyycKssYyR2r gS045Vy0TsdF0SLOnqf51zEBNnC/x0tPThj0r7n46eo0/4F+qsOANI5opv8ulp7TjDmW tBAJ8LEqnfuKVpkzk+BxmNDGJMkY640ScQuFp50gZqK1OaHl7tpCkOd+HonCIg20gglx /LOJKlwm0Dv3ukxOlh6KKBWUISpTxqQ4+OGDw5B4CdBFqr6o+F88rQTXs38z9SqKWAWc uAoWwbVhk89ILt5RKpBBbpt1qWoOYvfQgTx5Jk0hlPL3inrbVCRhnNimA7V3VqBEjQnj +RRQ== 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; bh=cGAJoan4B9O593ZoXcT9RzOP5KLkia4jZDLI7E+9tcU=; b=RqUiGnCV4wcJuuC8Xz+XLLvsYJexU573pj8pGah9XB9AADT86CVtnrZmgpg54cmPy/ s3f/qZNGxHkw0fZyJYxBfbPpphjSvbPw16S4BfBxsOYEHWdJ9A0q8moWIhfDnYDWunVL 3dRzm1UgxCX6eY+rTEywBI8VrKmF7zp8ONOLTj8G2zOkOHa295vVQoRUAj79aJqpQMpm b3VkC6LmY9F3ZQgNSC1YsTGqKr44vjOzpoJ3iyTdslAqCeK3tjdMtMXLEZsiPWw+1Agm SBIzKBfPiQ5K0B9Utihy2zTZzv4V18BKZBycjvztMarcy3xF0rkg8MXhLfxQvrTs463m FGZQ== X-Gm-Message-State: AOAM532A2EINgLyh+NwkalLbXmxdFYXMenEERr6osAKJu5MKaUwvC+Ay yCkALre1P0/fxf/ccHaZTtRc47kzW34= X-Google-Smtp-Source: ABdhPJz0OSyl7nFicaKz0+iHBOiHgfPfj7CRaS3tJ3x9hd/JNRvfVF1ZQg0/4ZpNfjdKNdM+5+O93Q== X-Received: by 2002:a62:1901:: with SMTP id 1mr1143829pfz.160.1596651457654; Wed, 05 Aug 2020 11:17:37 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:36 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 14/21] target/ppc: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:56 -0400 Message-Id: <20200805181303.7822-15-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x52e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, cota@braap.org, "open list:PowerPC TCG CPUs" , peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/ppc/excp_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index bf9e1e27e9..4530230d65 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -870,7 +870,9 @@ void ppc_cpu_do_interrupt(CPUState *cs) PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; + qemu_mutex_lock_iothread(); powerpc_excp(cpu, env->excp_model, cs->exception_index); + qemu_mutex_unlock_iothread(); } static void ppc_hw_interrupt(CPUPPCState *env) @@ -1056,14 +1058,17 @@ bool ppc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD) { ppc_hw_interrupt(env); if (env->pending_interrupts == 0) { cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51B27913 for ; Wed, 5 Aug 2020 18:22:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 28D4F22CA0 for ; Wed, 5 Aug 2020 18:22:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E/xsOwj1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28D4F22CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O3K-0004U3-AI for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:22:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyx-0004eW-Nx for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:44 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyw-0006VE-0u for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:43 -0400 Received: by mail-pg1-x541.google.com with SMTP id x6so9768012pgx.12 for ; Wed, 05 Aug 2020 11:17:41 -0700 (PDT) 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; bh=YM01JZCOBFTkObfq+41JWuhzyHiJWJ7EohnvO1vdIJU=; b=E/xsOwj1out5jTDw1B6uHewMdZZssRhI0qYSGvOkDZ8q6nMosifaO3SUYGRsaBrefG lCS6oar456DouWXOhlB8jJwebXTQJBkXUBBT3yMi31IV4n5ivkGztic6TDWfqGKUTl5J dAlDI4wDLoElA1Q13fhWkuZPLGirHNQtYZtr5WQyIXDJFAs/T0fzVaQZ5E1tBjz1E//v cLbSnZVD5h+HDdfIPibvT7lx4V5TC18YZc3vgwxZLDCp+E9ZEHLOre+dDUhrjxPxDDyD ETTYsY8MPdmf7V0Kgh2qNVG73U/Heu4NEuXS+HXK0q5RG4oD5BFGQqJXDJAI9Me8IAoI vuiw== 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; bh=YM01JZCOBFTkObfq+41JWuhzyHiJWJ7EohnvO1vdIJU=; b=HKCqMhJRNBgOe9v91gCcMTZTwsUkMgraDPYZx4tYopsyh+OD+wIeNPC4T7PrlGLAZZ TBRG5fMM5Y1gClBpEGEdpwoC6BtSXvJdh5sVHZpVSasevyOqJmvCNdFM2Ru3MzaGFOsq JIY/1rfFjw9ZZfYEnRZIWVx7MIC/vuTJHueRPTdTJ/VkQGCYsGLKdpBRuoEDSIal+BiJ UfeQkMEus57YyUUixqhxfHeM0VMvDZuFkhN8FU2btXCg7qg7BMGeMRE6T9i/sxBsv7x9 cOzyqX0AM4IVZ2tjManWEykUtbGmfKHtn2+IepWR4dnJggS757SbJ4n7yeAAl9v2XyoL wszg== X-Gm-Message-State: AOAM531DIrA7tfrRFkVeoduLeayNzm71KNXNXagOACH0Z34qIbeSaiQH UFNofoRrbGu/AOu/ihdQx7kUVHA7Nvk= X-Google-Smtp-Source: ABdhPJxjuA9Ylj1mq4sVihjlFA2l6FIIAeNxChpioXsJuOaar6eJVj1oCra0DTnrID81k0Z6xroI4A== X-Received: by 2002:a62:647:: with SMTP id 68mr4820009pfg.45.1596651460295; Wed, 05 Aug 2020 11:17:40 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:39 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 15/21] target/riscv: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:57 -0400 Message-Id: <20200805181303.7822-16-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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=unavailable 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: Alistair Francis , "open list:RISC-V TCG CPUs" , robert.foley@linaro.org, Sagar Karandikar , Bastian Koppelmann , cota@braap.org, Palmer Dabbelt , peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/riscv/cpu_helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 75d2ae3434..5050802e95 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -80,14 +80,17 @@ bool riscv_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { #if !defined(CONFIG_USER_ONLY) if (interrupt_request & CPU_INTERRUPT_HARD) { + qemu_mutex_lock_iothread(); RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; int interruptno = riscv_cpu_local_irq_pending(env); if (interruptno >= 0) { cs->exception_index = RISCV_EXCP_INT_FLAG | interruptno; riscv_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); } #endif return false; @@ -822,6 +825,10 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, */ void riscv_cpu_do_interrupt(CPUState *cs) { + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } #if !defined(CONFIG_USER_ONLY) RISCVCPU *cpu = RISCV_CPU(cs); @@ -982,4 +989,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) #endif cs->exception_index = EXCP_NONE; /* mark handled to qemu */ + if (bql) { + qemu_mutex_unlock_iothread(); + } } From patchwork Wed Aug 5 18:12:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3D5414B7 for ; Wed, 5 Aug 2020 18:28:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 98BC722CE3 for ; Wed, 5 Aug 2020 18:28:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Jw+hFPvo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98BC722CE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O9N-000530-35 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:28:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nz2-0004hY-4u for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:48 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:33227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyy-0006VW-IX for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:47 -0400 Received: by mail-pf1-x42c.google.com with SMTP id u20so1266839pfn.0 for ; Wed, 05 Aug 2020 11:17:43 -0700 (PDT) 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; bh=JzRY4u611ZdJJJ8DEPsiNDmT76OIm6iIPSor9aPp4Js=; b=Jw+hFPvo12d3SzroLf6sE8yRIdWsovt/PtjWwfq///ibh32KL/jD2mtDE/rxSh1ogT SyooaIom4hPIWQOo6gg2z7xP1SpuyMmWTsJxrc+CTK50OOG6cGha3uFswAlSR4cP3+uQ nSJp+30fuqRJgnij/j54TCYnshNHDjmwswEEYl9+y4HuY2171QHH6sI+XTQYVXswswM2 BMIv9lw61gcPkLqKWxyncXWumq+KcJyD46gKFnY1QViGouHuEthZPHBrmlMkLHe6J6aE xblHOaOzILnVytoOYF1B05xJYN1lY3xNuZyOxvHROVAoQegFk2MGCGbDmMPzHwwSZzu3 VnzQ== 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; bh=JzRY4u611ZdJJJ8DEPsiNDmT76OIm6iIPSor9aPp4Js=; b=WNCaP8PRP0rkH+f5cQQbZVlOgYdfF1t7fdAUKqurOM3V9cFc547Rvnzgkzw8A+tZEw WChY+Yr+Rc4py+PS0EnUEYRLGw5Cx3WzHd/9KB9MJGUyi7Qhk15mSp2J2wuhAHt0Gkb9 lPbQqXh/c9LOVmdgyhlFxYFBNg7Y7qsgN8+rdenPSvCWfnPVaXUKLfTVceCF3yYHzbQX qUMN2lbRE0tJaRZ3QSG4vdXlijrI7hrH19VaetCBDQs1J2f1wflwYt3CqVKusrT9IjPk qUZuJY07xy6K34xkChQIEtj4qqPlcFRBbieAG+uAYtUCEmbooNJ0+4iqxZ+huDdpTHrz yLnQ== X-Gm-Message-State: AOAM530jxP5bpPVY377bkwv0/sqV4spd9dwoI25Qm7QtQUJmzyYNblb1 7gtom9mIkC3mHWIhQO2FHW7T6vc4Qa8= X-Google-Smtp-Source: ABdhPJx/AW+EHhwLcrEOO45nyLyUnDkbKDWiA+7hiCpLk5p0G8iMv8chARC97f4c5P9Z9jwn29HXQw== X-Received: by 2002:a63:1a44:: with SMTP id a4mr4130118pgm.281.1596651462691; Wed, 05 Aug 2020 11:17:42 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:41 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 16/21] target/rx: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:58 -0400 Message-Id: <20200805181303.7822-17-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x42c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Yoshinori Sato , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/rx/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/rx/helper.c b/target/rx/helper.c index a6a337a311..a456b727ed 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -48,6 +48,10 @@ void rx_cpu_do_interrupt(CPUState *cs) CPURXState *env = &cpu->env; int do_irq = cs->interrupt_request & INT_FLAGS; uint32_t save_psw; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } env->in_sleep = 0; @@ -117,6 +121,9 @@ void rx_cpu_do_interrupt(CPUState *cs) (vec & 0xff), expname); } env->regs[0] = env->isp; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request) @@ -124,6 +131,7 @@ bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request) RXCPU *cpu = RXCPU(cs); CPURXState *env = &cpu->env; int accept = 0; + qemu_mutex_lock_iothread(); /* hardware interrupt (Normal) */ if ((interrupt_request & CPU_INTERRUPT_HARD) && env->psw_i && (env->psw_ipl < env->req_ipl)) { @@ -138,8 +146,10 @@ bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request) } if (accept) { rx_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:12:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702195 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17EA8913 for ; Wed, 5 Aug 2020 18:27:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 A3F6122CE3 for ; Wed, 5 Aug 2020 18:27:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sfLqYx+C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3F6122CE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O8o-0004Zo-IH for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:27:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nz4-0004k6-2A for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:50 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:46390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nz1-0006W2-3h for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:49 -0400 Received: by mail-pf1-x442.google.com with SMTP id 74so14954298pfx.13 for ; Wed, 05 Aug 2020 11:17:46 -0700 (PDT) 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; bh=WMl3AIWSt1TrS8ub7e6y3EFYj5c+15bBo75uZcYRAVU=; b=sfLqYx+CkXOIMiam4y4J2nto/nWPmU5jv63NiJXbtzGqxWnx4fB+7shF6g9Rz13k8M fYfP76nihiooh7VefqazSomDmyeVijTSJZvlctSiEGBZp03HWfU8CKghim03v6KYlqMc fPjGzi9LIFGSFuZMXCMsNSu4KwTgwv7VIcmA3ymkqIe4n38leNb07q7YkyCyuzYayE0l WmIdT7ELxsFjXnulpdDSv+EmD9VSsJ6yk9MVcdmFCcjmedIbQKUF0jfPJdmz0vyiQQoU BUSY+y16Z4l6ZbaC16/9yqGZlnJ0UemWrj5q/Y+JFfNitXsijE50lrylaby3U6FiJL0n KuXA== 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; bh=WMl3AIWSt1TrS8ub7e6y3EFYj5c+15bBo75uZcYRAVU=; b=ho+Uwly4co1L1sIa4rIFY183RfJJxkXLwWmK9qNz9K13wAHSd09oLeVcCDcYVCUeSN a/L3ie8sYnEvjRFRzpmBqqyFbuEoa9PJ2waLN5KE/Sfty3t17LGa5q66sJssWTQAvdIN NcrPCldY4/Buu6GdNq3FFef4yPItv6Bp0z7xzpC2Wm3wfRxIk9XPluEEnMfuTS/I7rvx +JI0mKBI0w/aiC5HTsMMkHtVsulWImKu8qwjcdr2tfqFGqhR0DCYYNNTZxf3yL+Xm0QK sCWZlKeRw3Kv0bhMJw+ikQu3l7ocFeo9THIi+cwbkXJ9LmKwSSelPFnA5f0vWrFE2yYL wDhw== X-Gm-Message-State: AOAM5339pjQllsQb/7MgdUSzf/VWumVu6qsHvPqaG/EryhiSe6Cat2Cz yvqES760o1ADlyMa0uYU5NBX2I1oBjg= X-Google-Smtp-Source: ABdhPJwc9cazGiwWPYv78LG7ZqWIfNSQgGf/yeeT/1FRiKN8tF/u3yj4TGQpwlr0MeUTUafARWUmAQ== X-Received: by 2002:a63:338c:: with SMTP id z134mr3990719pgz.245.1596651465440; Wed, 05 Aug 2020 11:17:45 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:44 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 17/21] target/s390x: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:59 -0400 Message-Id: <20200805181303.7822-18-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Thomas Huth , robert.foley@linaro.org, David Hildenbrand , Cornelia Huck , "open list:S390 TCG CPUs" , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/s390x/excp_helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index dde7afc2f0..b215b4a4a7 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -470,7 +470,10 @@ void s390_cpu_do_interrupt(CPUState *cs) S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; bool stopped = false; - + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } qemu_log_mask(CPU_LOG_INT, "%s: %d at psw=%" PRIx64 ":%" PRIx64 "\n", __func__, cs->exception_index, env->psw.mask, env->psw.addr); @@ -541,10 +544,14 @@ try_deliver: /* unhalt if we had a WAIT PSW somehwere in our injection chain */ s390_cpu_unhalt(cpu); } + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD) { S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; @@ -552,10 +559,12 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request) if (env->ex_value) { /* Execution of the target insn is indivisible from the parent EXECUTE insn. */ + qemu_mutex_unlock_iothread(); return false; } if (s390_cpu_has_int(cpu)) { s390_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } if (env->psw.mask & PSW_MASK_WAIT) { @@ -564,6 +573,7 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request) cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HALT); } } + qemu_mutex_unlock_iothread(); return false; } From patchwork Wed Aug 5 18:13:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29EA3913 for ; Wed, 5 Aug 2020 18:24:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 0206E22CA0 for ; Wed, 5 Aug 2020 18:24:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wej9GzQV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0206E22CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O5F-00082o-9Z for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:24:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nz7-0004oi-Jb for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:53 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:41044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nz3-0006WX-DL for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:53 -0400 Received: by mail-pl1-x642.google.com with SMTP id f10so830593plj.8 for ; Wed, 05 Aug 2020 11:17:48 -0700 (PDT) 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; bh=eY79OI2NziyEJvuRHl1nh9tYXBtyJDeusaPNFa05tj8=; b=wej9GzQVC8LKvXsuCL2CxODp85b71XEKPDifhMVNT67NbQ+2Z9k5hnv+WVaFSv32mq thIhWIGJ0vgsECpMSD6yp/gBy/pMdnj+wdvdOGoS0hKk9vA5Az3HgnJtkqRUNC2XYJSl lm27BcNFgFC+9/K5H89eEmTY+uTTbvTJm/RMEFp14uv6sstlHBN70ueZsQv+HTrUvnsC T6TO27dbHpibU5Uv7pFgUZ4BYDu9danOngbv1KU9na4gJwMMaVW2MphempSv7dZooCKL KbZe0s8GFjzEkE6Ta0/gQxb4nn3UaWkievFiEKaukStJTNUnokcQPiD69wQK/XRCLotN 91oQ== 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; bh=eY79OI2NziyEJvuRHl1nh9tYXBtyJDeusaPNFa05tj8=; b=Jpc247q5vsIBaLVDroICMDE2Dn7d7KJ30N347CttRWAYLZm7NLg8LuUBf+bxx096Bp XXznSaDmeLq2qWrI/Vt29EllqXv9aGrneqDgn6pop7fkxOZii51SfUJsSMYzQYGsC6W6 jkUVhWxESO39JIttESKp78y1aMlBuFUb3psD0PNbEq1aisBK9/zMwSaM2hxXm4WKGi0e UthRdbbv4ZDuEfGCrpOVJzAetdmG0mLCqKURIF5aUtqfflsUR7WgmTJa2bpAtjw+gT0x ykEVxrw1ff0QZuatkbEBIv70eOdHpzGF/EIYKflGMNUYsqukLADZN+yWb4mraCwMdaZ7 SHbQ== X-Gm-Message-State: AOAM531oyh9euUQ/urECIGQVCI6nRFoeviktDXL//oo4ahsSyTCyMzoE VPWOw/2CJyEp8tigSiuLQfNJU7Kqiyw= X-Google-Smtp-Source: ABdhPJxkiEjJhtwDrsP26RCPB8iIiTN7NUGYU4YxbtjeUSuZhcjXcBEjfPVDwmbg3bOkNSQGhmyBMg== X-Received: by 2002:a17:90b:285:: with SMTP id az5mr4509628pjb.118.1596651467681; Wed, 05 Aug 2020 11:17:47 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:46 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 18/21] target/sh4: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:13:00 -0400 Message-Id: <20200805181303.7822-19-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Yoshinori Sato , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/sh4/helper.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 1e32365c75..c4d5b9a374 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -62,8 +62,11 @@ void superh_cpu_do_interrupt(CPUState *cs) { SuperHCPU *cpu = SUPERH_CPU(cs); CPUSH4State *env = &cpu->env; - int do_irq = cpu_interrupt_request(cs) & CPU_INTERRUPT_HARD; - int do_exp, irq_vector = cs->exception_index; + int do_irq; + int do_exp, irq_vector; + qemu_mutex_lock_iothread(); + do_irq = cpu_interrupt_request(cs) & CPU_INTERRUPT_HARD; + irq_vector = cs->exception_index; /* prioritize exceptions over interrupts */ @@ -79,9 +82,11 @@ void superh_cpu_do_interrupt(CPUState *cs) should be loaded with the kernel entry point. qemu_system_reset_request takes care of that. */ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + qemu_mutex_unlock_iothread(); return; } if (do_irq && !env->in_sleep) { + qemu_mutex_unlock_iothread(); return; /* masked */ } } @@ -91,6 +96,7 @@ void superh_cpu_do_interrupt(CPUState *cs) irq_vector = sh_intc_get_pending_vector(env->intc_handle, (env->sr >> 4) & 0xf); if (irq_vector == -1) { + qemu_mutex_unlock_iothread(); return; /* masked */ } } @@ -180,14 +186,17 @@ void superh_cpu_do_interrupt(CPUState *cs) env->pc = env->vbr + 0x100; break; } + qemu_mutex_unlock_iothread(); return; } if (do_irq) { env->intevt = irq_vector; env->pc = env->vbr + 0x600; + qemu_mutex_unlock_iothread(); return; } + qemu_mutex_unlock_iothread(); } static void update_itlb_use(CPUSH4State * env, int itlbnb) From patchwork Wed Aug 5 18:13:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE046913 for ; Wed, 5 Aug 2020 18:23:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 C6E9422CA0 for ; Wed, 5 Aug 2020 18:23:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fCz3LSoj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6E9422CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O4v-0007R3-3M for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nz8-0004rG-Gn for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:54 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:39350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nz6-0006Wk-Fc for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:54 -0400 Received: by mail-pf1-x429.google.com with SMTP id z188so15373864pfc.6 for ; Wed, 05 Aug 2020 11:17:51 -0700 (PDT) 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; bh=8sH61aMZL0itQ+WBV8wzY8AM/bADwemnnaBh5BIpH6g=; b=fCz3LSojL/mhv5v3nckhBGWRUG7cyv9P8hKllNSQNhq8f9Xv6dxbBwSEWCKsgs4kPJ vY8LnZA2mEUhRIsytLFG+XaPY1P+1sGKasspAqdbIgH1MCP2slmtPiZTv28xTr8k9Q0W JFBNABFtTbIaveWNu20Tki6ptKy32MySBRw9QKR/xhbT3ZZPno/rGbH7R138sUfKUd4+ wTYx2qWNAjGoy15zIOsf0j5MtOXw59FpU0SePvcpPR0wm4PZygbg9eKNXLC9dg0NXKHq 0IX5A8qXPLLwEVXmxbMy/HLeCm5Uum6dMc/VYS36mlAbvzL2yZqZLfBb3qpF+y0yxPCI bKSA== 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; bh=8sH61aMZL0itQ+WBV8wzY8AM/bADwemnnaBh5BIpH6g=; b=Vfr2sY6hsz69kH+BMdOMA0Jt36xVw0vRpFCayjyHMmC+kZRiGattdOuCIIAZ/9hiJQ 15o8iUjvdVd95sCwW+Ftii7tsjRLzpu4c0sgu853bKjM1dkBJQD6EZKbRhdEfz7OKpyK Ms/MmshAZgIes4N6slxUut2U258EWMqlrpcJwdPSldhCZl6az7/2feovF/P/xn02Necw Fgv05Zl/v49owqOkfPzfL+0yDpp6qYS0+g4WuWMfgxUCS+tgQfVP+AoResrXvTMdNcAQ Ol9nA3Hn9X6c0g+kigd/8hqxlaPbQrn7/ExtasT9g7ZV6BP7p7HJjMjjgHSS3EGUgSBn lLzw== X-Gm-Message-State: AOAM530KRmwCQeAAs98OQX07YRdRDZJiausuycAGpPjPYTV9UrNSQFrd Jb62/8Q8/AP+EvrmgVUweHVRh0LQXAk= X-Google-Smtp-Source: ABdhPJyZkc+7cxW/eMG/ca8UQi+8pgPeqbH3eG9XzMYMbweOA+4eRNvBmHrhiTYzmS6FiLU5p0cm9g== X-Received: by 2002:a63:4281:: with SMTP id p123mr3853501pga.94.1596651469963; Wed, 05 Aug 2020 11:17:49 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:49 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 19/21] target/sparc: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:13:01 -0400 Message-Id: <20200805181303.7822-20-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Mark Cave-Ayland , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Artyom Tarasenko Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/sparc/cpu.c | 3 +++ target/sparc/int32_helper.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 20c7c0c434..13b5a038e8 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -79,6 +79,7 @@ static void sparc_cpu_reset(DeviceState *dev) static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD) { SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = &cpu->env; @@ -90,10 +91,12 @@ static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) if (type != TT_EXTINT || cpu_pil_allowed(env, pil)) { cs->exception_index = env->interrupt_index; sparc_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } } } + qemu_mutex_unlock_iothread(); return false; } diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 9a71e1abd8..3940e945ed 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -69,7 +69,12 @@ void sparc_cpu_do_interrupt(CPUState *cs) { SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = &cpu->env; - int cwp, intno = cs->exception_index; + int cwp, intno; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } + intno = cs->exception_index; /* Compute PSR before exposing state. */ if (env->cc_op != CC_OP_FLAGS) { @@ -115,6 +120,9 @@ void sparc_cpu_do_interrupt(CPUState *cs) "Error state", cs->exception_index, excp_name_str(cs->exception_index)); } + if (bql) { + qemu_mutex_unlock_iothread(); + } return; } #endif @@ -136,6 +144,9 @@ void sparc_cpu_do_interrupt(CPUState *cs) env->qemu_irq_ack(env, env->irq_manager, intno); } #endif + if (bql) { + qemu_mutex_unlock_iothread(); + } } #if !defined(CONFIG_USER_ONLY) From patchwork Wed Aug 5 18:13:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFAE8913 for ; Wed, 5 Aug 2020 18:26:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 A87A022CF7 for ; Wed, 5 Aug 2020 18:26:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MBm7lEit" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A87A022CF7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O6z-0002IC-Ty for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:26:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nz9-0004tr-H0 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:55 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:37759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nz7-0006Wv-M6 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:55 -0400 Received: by mail-pj1-x1041.google.com with SMTP id mw10so1079426pjb.2 for ; Wed, 05 Aug 2020 11:17:53 -0700 (PDT) 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; bh=BjiLVDDEqoIBJt1y3HRzPMRPdgMoMf8GueSFlFqkhhc=; b=MBm7lEitcGCY7AbHi6skbhjWbJ/rDY+d8AUujZEUhFJ8g19yEdbJIoVDsPDn6k6fEz 5oE5FQGhaA3JmmjbA3LNwzd6R3PCZcho9Lfb20LqUmUWp7f9lkOofRe96DwyU2SwkxfP GlcNfoVRXZCamvXErM63U6dD3Fsl+PV+cC5qOKoYp7UuNFbmmSSPlYUpXaVtxHnnYmGt eU7aK7VUeJvV+4LYVekRDiGmP6t03D75lEnnTDPYGQUbMarPhNfOeVeJL+pkHgJFSFko WWAjrJeQ/fol9wpFzihe09Rn9OOW1N1YVgSxbMJAqPLPldqkjbjt+P9EjLFQCnk2+0U3 XO9A== 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; bh=BjiLVDDEqoIBJt1y3HRzPMRPdgMoMf8GueSFlFqkhhc=; b=KA3a/xFvPfiznAf2Sl3BgbKUgyEDxnng0fN08o1Ta9Fc5lWWFmTWomR+bhyojy3Za8 MjS5dOfuRJwZM+aUfOI5ByqgxclGNxOo6uLmgUR/mCOJkYoanb6p4XTNoLrwa+SpDQjm CTCijVqurgK/xEDGFK351u6fBSsqcL/DNRdE0Es4j7FAbMeSTMvCrU/A0qlWF8KokrWq kd/O3iYwHzALwpsKrbxbN60mhYE44OFBgi6Gl2RY0gDjURbvlyCSx5w3j1df1w0sMcgw 33PQND2YvHTGfc0sfwcq/yZ8KCaRHBOUUroEiDp6v/d02Ft/RVpa9JMGxzQNBPYvpXIx FzXA== X-Gm-Message-State: AOAM5301nTUPfw9num3q1qB/4Cp4Any9POHuTU2oHDmuwpTyNFDWiyBT MWzfiQM6RnzPUBepuHxk6pvUkqbumDo= X-Google-Smtp-Source: ABdhPJx8Il7vymRVwkEW2ud1RveHV9WNsGO5GpPmEm2CjdPywxgfoLQzXwmAylcakI9hvrhBvM5fgw== X-Received: by 2002:a17:90b:1287:: with SMTP id fw7mr4323117pjb.218.1596651472139; Wed, 05 Aug 2020 11:17:52 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:51 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 20/21] target/unicore32: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:13:02 -0400 Message-Id: <20200805181303.7822-21-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1041.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, Guan Xuetao , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/unicore32/helper.c | 3 +++ target/unicore32/softmmu.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/target/unicore32/helper.c b/target/unicore32/helper.c index 54c26871fe..d79284d224 100644 --- a/target/unicore32/helper.c +++ b/target/unicore32/helper.c @@ -169,6 +169,7 @@ void helper_cp1_putc(target_ulong regval) bool uc32_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD) { UniCore32CPU *cpu = UNICORE32_CPU(cs); CPUUniCore32State *env = &cpu->env; @@ -176,8 +177,10 @@ bool uc32_cpu_exec_interrupt(CPUState *cs, int interrupt_request) if (!(env->uncached_asr & ASR_I)) { cs->exception_index = UC32_EXCP_INTR; uc32_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } } + qemu_mutex_unlock_iothread(); return false; } diff --git a/target/unicore32/softmmu.c b/target/unicore32/softmmu.c index 9660bd2a27..ca9b92aad0 100644 --- a/target/unicore32/softmmu.c +++ b/target/unicore32/softmmu.c @@ -81,6 +81,10 @@ void uc32_cpu_do_interrupt(CPUState *cs) CPUUniCore32State *env = &cpu->env; uint32_t addr; int new_mode; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } switch (cs->exception_index) { case UC32_EXCP_PRIV: @@ -118,6 +122,9 @@ void uc32_cpu_do_interrupt(CPUState *cs) env->regs[30] = env->regs[31]; env->regs[31] = addr; cpu_interrupt_request_or(cs, CPU_INTERRUPT_EXITTB); + if (bql) { + qemu_mutex_unlock_iothread(); + } } static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address, From patchwork Wed Aug 5 18:13:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11702211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EF08913 for ; Wed, 5 Aug 2020 18:29:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 3450D22CB3 for ; Wed, 5 Aug 2020 18:29:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ppsj5mQY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3450D22CB3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3OAU-0006Er-Te for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Aug 2020 14:29:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3NzB-0004zb-RM for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:57 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nz9-0006XG-Ub for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:57 -0400 Received: by mail-pl1-x641.google.com with SMTP id f10so830885plj.8 for ; Wed, 05 Aug 2020 11:17:55 -0700 (PDT) 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; bh=f4dp87j0JbOgZeF9Q5qKD4L3G1MqZ8pb/SPlrQlUp44=; b=ppsj5mQYzg/Kr8tUEwM3tmcuTjfMRCrWF4RrbFmBPoemT/+eavST4FAzusKdk2UUAI bIfBxQRoMLAgPliH+m1CrXTBld+ILPMjtZkOkw3LwwDHYdWPGlPvRsqMg3yBy/Y/5B5v 6foe2wskP6azX/c+GclfKEOTZ+QDlKCxgHhSJ9ZryXg6nX0zUo6m66BjGAYWQcbcVYnj VlhTt0K8b/nnkg+FCSsVNIwfkVqNMfiE4kLTlQY0qEK3euuNZz+fIIvylURCsF9ItYDf /zt/sqEC3+Sq8CzrYnJlGW626qVn5JhjZWiQB6SXvbQotfp0GWo5jFQON1pDjvD2A2q/ 7L6A== 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; bh=f4dp87j0JbOgZeF9Q5qKD4L3G1MqZ8pb/SPlrQlUp44=; b=GiZ2LE3AZ+6uLliPTgb4RA7sXN3cHWe2O08c6BMrv+REOzMk5Nq6ul+/jH9LcZ+iMN uRLHdh6c0zXvuxcE5LaZgzlad91A1LfBh2HrlwlmUk0aii57DOhLJe/A2dGaoIZeUW02 0xpQuxGB5UoNl9yooXwzcdvzFxxKI+ETDVKm8c9QQbVN4rs6Kx0Zrz2tVV0Lu3/xQEiV lLVVoXFxMjzPCT0NNU68wxUfvckrXFFwSK0/7dVLtamdkJ22C+k5At1Oqt0agjyDsLlz pdMhTU7YpqTznaTeiIZqUz0RuV1t7tQ1xhHuRYtehFDJBVgGQr9ru0TIC0LTre1GQqYm nsJw== X-Gm-Message-State: AOAM531RfA2MloInkold5lBcSRnA5IvYvtGYY3H7bN6FOfqFgxTcfa1I +wd2e5WXz8/+TbzolrvAqEVwwpNV8x8= X-Google-Smtp-Source: ABdhPJwS1OZeyatJagggET6+gLKyYY5uNtT278Rqy94M+Vb+2QkJSIHtUyrEiVlQJrhsHVleqfPKeA== X-Received: by 2002:a17:90b:14d1:: with SMTP id jz17mr33704pjb.98.1596651474313; Wed, 05 Aug 2020 11:17:54 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:53 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 21/21] target/xtensa: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:13:03 -0400 Message-Id: <20200805181303.7822-22-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: robert.foley@linaro.org, Max Filippov , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/xtensa/exc_helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 01d1e56feb..fd33a56847 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -200,6 +200,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs) XtensaCPU *cpu = XTENSA_CPU(cs); CPUXtensaState *env = &cpu->env; + qemu_mutex_lock_iothread(); if (cs->exception_index == EXC_IRQ) { qemu_log_mask(CPU_LOG_INT, "%s(EXC_IRQ) level = %d, cintlevel = %d, " @@ -252,6 +253,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs) break; } check_interrupts(env); + qemu_mutex_unlock_iothread(); } #else void xtensa_cpu_do_interrupt(CPUState *cs)