From patchwork Thu May 21 16:39:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187051 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp1727790ilb; Thu, 21 May 2020 10:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd88BlzuLMS8xf7+gsZ/sGdsuyRjq6zbZjfrHHCdw6PKj8ZJGg0PunOxWwM58gDAfRTvA2 X-Received: by 2002:ac8:2f50:: with SMTP id k16mr11923279qta.392.1590080689702; Thu, 21 May 2020 10:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590080689; cv=none; d=google.com; s=arc-20160816; b=CwhVX0zzvelVZU2dZVVRYcxdGtOaCoLCPruSVkoVXjjJlMDz7bhbmsJUa+gvGmns6J GikXOODAqsocOvdznxESliGwcy5PrPxogsBZ20dFuDkROr7SnxqYrgqlvbmpgMluXO3R YVCvC/6HAxhb94vvpEhifEUuLgnWBR9xYXQ5vsc9Fa6Q1O1wnek+CBCQN4E490fqrTUN y1a3r5SwGnIMyu9tBsJMUmCj6B4hyvF+hUy+v8Xc4XNxvTFguY6tzsaZp0p7IsNwzcP/ z60nuT1A0GqErYzNsfWfaBuFMsSwo6IUfaIzv9x1GzBOxJmZSKLSfcTjffBW6IEu/KNl fZgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=sh7ma3RXOutsPCVp5vgyQfkJaobdB9KSp9Dt7UwZtpM=; b=I6WHGomf2Jqgdzy75Q/tpcAWbJ457FN0UaYy0dMwavEGTWqHggr0l6zLNjygzmhyDV 5ySwL0t3wgRr6U5PN4ucYIJELBjla76fX3Eindu1Cc6huy2wM948CU//lQJmNfnzSiKa 7ylk45LVNTa0Ne6EnNdPlz2b+NqyCM1k6A+mbf1hi2/p+9Cp9b8aYFEV3wD+H+4UPS47 vQTtFMBLowhXAq8sftGJnrf15BrkAN9ljC+HgWw+IHnDlnlSEug89zoScquOAoi64BME AkF8VXT+tvl8KWyxev6iKgT3Surm2sltGMAtPHntkUxhUX/lSB6IEMCuXzxLoPTIaKC1 k0kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wbkhvCZL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r25si3591220qtb.77.2020.05.21.10.04.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 10:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wbkhvCZL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbocj-0002SM-6O for patch@linaro.org; Thu, 21 May 2020 13:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jboJF-0004Ud-Ck for qemu-devel@nongnu.org; Thu, 21 May 2020 12:44:41 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:40824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jboJB-0006im-Pz for qemu-devel@nongnu.org; Thu, 21 May 2020 12:44:40 -0400 Received: by mail-qk1-x744.google.com with SMTP id g185so7848143qke.7 for ; Thu, 21 May 2020 09:44:35 -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 :mime-version:content-transfer-encoding; bh=sh7ma3RXOutsPCVp5vgyQfkJaobdB9KSp9Dt7UwZtpM=; b=wbkhvCZLW0BSpV2AtX9VeMZE0g8qqRM09Exw85cXX+CGsV8LO9g8zyEqLosyrb5O6l 4VxFF4FefEF6VTqjX2s7saivoJk0R5TSSCIpjsMkIDyRb/PVvHlvGY79msMzyGpzy2AJ VNJ//fKzhVGsZyo10teOYQt2lLtGTJnhxihKdXmj70Wj1oQjC2l3NSwJqCC+QjuceXE1 8eJPv7TdaTLpzq/Q8h+v+d9VVwkgdYcH+iiOq5+oaSCR2Kmw2HMlNPSCD32p5LpaMWZW VqeCXfYwDTbl1MVCfIcUqqH4rJZhiU3Qg7qHRWCrZrzrq6Xshh9PRSsSv1UJ8NeySu0i PKwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sh7ma3RXOutsPCVp5vgyQfkJaobdB9KSp9Dt7UwZtpM=; b=LyTReodp0ORcT3qfF9NuMN9c77wrBaHeRD2diM9HKVsV7xJRjOjLUC8zCIL5UtqwWq KrgYG17Puh/h42XbgTppwX7ATTZBeQIopmRQyf+Ig0a6x0tN/QFzAmba3HyLECEZvnck S3WTElz53xMcJ76NPEtWr7urSeXehj3+lWAS6MaANrzoe3LqNl3HQo8GmWOgte1YrtW9 fJ08ghejVgcMuf+UVCcAG7kIljLx4zKLBG+BYhIvlew8UQI23DVTxCuGwIjLiSMxEwdb dQUk+EeryXVL0r3N6pho9AdigOOpar8oxGU8/AasbIbkeZkcnhT1KW45zi431fDPbuyD DWrg== X-Gm-Message-State: AOAM531/e3qx+4Wk3ST4YpDbNiJkrE4H9zXxHaiHALQzTchIzLt5Z5GW Ansv+4SQQztaOS6+1aEolOBCC9MSp4GIaA== X-Received: by 2002:a37:6cd:: with SMTP id 196mr1800690qkg.393.1590079475064; Thu, 21 May 2020 09:44:35 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1944:c530:655c:5583]) by smtp.gmail.com with ESMTPSA id x24sm5923829qth.57.2020.05.21.09.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 09:44:34 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v9 60/74] accel/tcg: convert to cpu_interrupt_request Date: Thu, 21 May 2020 12:39:57 -0400 Message-Id: <20200521164011.638-61-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200521164011.638-1-robert.foley@linaro.org> References: <20200521164011.638-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::744; envelope-from=robert.foley@linaro.org; helo=mail-qk1-x744.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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: richard.henderson@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley --- accel/tcg/cpu-exec.c | 15 ++++++++------- accel/tcg/tcg-all.c | 12 +++++++++--- accel/tcg/translate-all.c | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 099dd83ee0..b549a37847 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -431,7 +431,7 @@ static inline bool cpu_handle_halt_locked(CPUState *cpu) if (cpu_halted(cpu)) { #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) - if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) + if ((cpu_interrupt_request(cpu) & CPU_INTERRUPT_POLL) && replay_interrupt()) { X86CPU *x86_cpu = X86_CPU(cpu); @@ -544,16 +544,17 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, */ atomic_mb_set(&cpu_neg(cpu)->icount_decr.u16.high, 0); - if (unlikely(atomic_read(&cpu->interrupt_request))) { + if (unlikely(cpu_interrupt_request(cpu))) { int interrupt_request; + qemu_mutex_lock_iothread(); - interrupt_request = cpu->interrupt_request; + interrupt_request = cpu_interrupt_request(cpu); if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK; } if (interrupt_request & CPU_INTERRUPT_DEBUG) { - cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG); cpu->exception_index = EXCP_DEBUG; qemu_mutex_unlock_iothread(); return true; @@ -562,7 +563,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, /* Do nothing */ } else if (interrupt_request & CPU_INTERRUPT_HALT) { replay_interrupt(); - cpu->interrupt_request &= ~CPU_INTERRUPT_HALT; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT); cpu_halted_set(cpu, 1); cpu->exception_index = EXCP_HLT; qemu_mutex_unlock_iothread(); @@ -599,10 +600,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } /* The target hook may have updated the 'cpu->interrupt_request'; * reload the 'interrupt_request' value */ - interrupt_request = cpu->interrupt_request; + interrupt_request = cpu_interrupt_request(cpu); } if (interrupt_request & CPU_INTERRUPT_EXITTB) { - cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_EXITTB); /* ensure that no TB jump will be modified as the program flow was changed */ *last_tb = NULL; diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 3b4fda5640..5eda24d87b 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -52,10 +52,16 @@ typedef struct TCGState { static void tcg_handle_interrupt(CPUState *cpu, int mask) { int old_mask; - g_assert(qemu_mutex_iothread_locked()); - old_mask = cpu->interrupt_request; - cpu->interrupt_request |= mask; + if (!cpu_mutex_locked(cpu)) { + cpu_mutex_lock(cpu); + old_mask = cpu_interrupt_request(cpu); + cpu_interrupt_request_or(cpu, mask); + cpu_mutex_unlock(cpu); + } else { + old_mask = cpu_interrupt_request(cpu); + cpu_interrupt_request_or(cpu, mask); + } /* * If called from iothread context, wake the target cpu in diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 42ce1dfcff..af8ecf3380 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2392,7 +2392,7 @@ void dump_opcount_info(void) void cpu_interrupt(CPUState *cpu, int mask) { g_assert(qemu_mutex_iothread_locked()); - cpu->interrupt_request |= mask; + cpu_interrupt_request_or(cpu, mask); atomic_set(&cpu_neg(cpu)->icount_decr.u16.high, -1); }