From patchwork Wed Nov 27 22:06:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 1201821 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hjWONevP"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 47NZhH3qlgz9sPv for ; Thu, 28 Nov 2019 09:10:07 +1100 (AEDT) Received: from localhost ([::1]:43662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia5Vd-0007w8-5d for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 17:10:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33794) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia5SD-0005dK-Ta for qemu-devel@nongnu.org; Wed, 27 Nov 2019 17:06:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia5SB-0002LF-TR for qemu-devel@nongnu.org; Wed, 27 Nov 2019 17:06:33 -0500 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:34109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ia5S9-0002IA-SI for qemu-devel@nongnu.org; Wed, 27 Nov 2019 17:06:31 -0500 Received: by mail-lj1-x244.google.com with SMTP id m6so18788918ljc.1 for ; Wed, 27 Nov 2019 14:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qc4fhvPidiFroBnj333xYm85MsYpPPDW+ASOMqwu3Z0=; b=hjWONevPmqr9P1/CJKMb5zNbQDTcZUL9RIaDEIj3ZieeKU+/yQ1Biae4yJ9YkpjR9p so+EXmmmVRFKxJ1T85Xh77aQyncWBVkP5cEGR8YMpionVvxViV1mP+Otm8mW5KKw6jVk 0YjUnsoCFVkBB58a+5NQbtY8tcQkBz55fE9KlnzdxCFCBhMYbwX+zWl5Y3RII3PT7iRC e4CsBitaIHKEgoZ+bio/0Ksl1a6hRAFupex6/aiulfq3Sc7Vha7B70n2vHoXU/TDDKOk 9XtE4sHjggmxEWqSo+v+7HRTCa51j7iY9bMYxEHvgJ/teoO+XqQ0qPeUR5XgrUmkaczq dILg== 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=Qc4fhvPidiFroBnj333xYm85MsYpPPDW+ASOMqwu3Z0=; b=fX6HZuudsgrpUE1BxNGv9oRnkpoVCegXEz9PZ5IY1XBp76cOsQWPbIvksrbul8qhye rgt0TglVJAitXDMavKjiFEVOQLVLiC5dIyRJwBcvoSCbbpM2DmWoa4EpcIlDc2d1sgFH qIxyP7vQdsGHUnF4Oa1ulfYF2c1hGTAQfm3WppMsErOP7rU3Mm1bBUlQws18DlVvksCK xF2vuDnpRyrzUB3VNlqp/IRuiPhOH9hyM4rHlL+eDq9gerqgs5fioLyeh4KgW5Ube9JK 5pnk0Ohumx0w8vUYCp4N7SQkWHv7XoJr+4UHkTRBX9gObrZqGxQ0PdEAvsiVXDoY4NWf u1ww== X-Gm-Message-State: APjAAAVHuTh5AgUcd4tnADNj/oxpM54wQcnnpJi81apx8yimGiV495rV ZUqjsbjSrHZdc5Bd+6d0+1goL3BV+mk= X-Google-Smtp-Source: APXvYqwrGIwLftk3VwmkyoE+XhsV58yTxHWQ1KqG2ZvSF83+fvJgtxwbbyXI0hQUsPdWni5MXx40mA== X-Received: by 2002:a2e:898a:: with SMTP id c10mr31965170lji.177.1574892386973; Wed, 27 Nov 2019 14:06:26 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id r7sm7655611ljc.74.2019.11.27.14.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 14:06:26 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Subject: [PATCH 1/2] exec: flush CPU TB cache in breakpoint_invalidate Date: Wed, 27 Nov 2019 14:06:01 -0800 Message-Id: <20191127220602.10827-2-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127220602.10827-1-jcmvbkbc@gmail.com> References: <20191127220602.10827-1-jcmvbkbc@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::244 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: Max Filippov , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When a breakpoint is inserted at location for which there's currently no virtual to physical translation no action is taken on CPU TB cache. If a TB for that virtual address already exists but is not visible ATM the breakpoint won't be hit next time an instruction at that address will be executed. Flush entire CPU TB cache in breakpoint_invalidate to force re-translation of all TBs for the breakpoint address. This change fixes the following scenario: - linux user application is running - a breakpoint is inserted from QEMU gdbstub for a user address that is not currently present in the target CPU TLB - an instruction at that address is executed, but the external debugger doesn't get control. Signed-off-by: Max Filippov --- Changes RFC->v1: - do tb_flush in breakpoint_invalidate unconditionally exec.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/exec.c b/exec.c index ffdb5185353b..1709b760edc1 100644 --- a/exec.c +++ b/exec.c @@ -1017,14 +1017,13 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) { - MemTxAttrs attrs; - hwaddr phys = cpu_get_phys_page_attrs_debug(cpu, pc, &attrs); - int asidx = cpu_asidx_from_attrs(cpu, attrs); - if (phys != -1) { - /* Locks grabbed by tb_invalidate_phys_addr */ - tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as, - phys | (pc & ~TARGET_PAGE_MASK), attrs); - } + /* + * There may not be a virtual to physical translation for the pc + * right now, but there may exist cached TB for this pc. + * Flush the whole TB cache to force re-translation of such TBs. + * This is heavyweight, but we're debugging anyway. + */ + tb_flush(cpu); } #endif