Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30083202rwd; Thu, 6 Jul 2023 00:10:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+G8pNzhg5HXrDs5Qrb7mK9ekX9s9OLQXOXx02q688fTCWmYsgM03swBQMWwZHhzR8CbQO X-Received: by 2002:a17:902:ed44:b0:1b8:6cbd:96f1 with SMTP id y4-20020a170902ed4400b001b86cbd96f1mr1153791plb.66.1688627445594; Thu, 06 Jul 2023 00:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688627445; cv=none; d=google.com; s=arc-20160816; b=UH2LUJjwyIa3zh2Qp+y6Bi4QhStL3RNlSRXQFLg55V4CSd1i6WtmivXYdKyjj9xQFc KfPLLmQymYScDIHAE2kpmfGLC6ME3ddIIMMoiTuWNBsQGuQsULsLn5ZgNnns7A8qRgMX 8mV7BOYPlHFuzbX3zaT0aUPLoPUIZl0QsaOTOAlQ3+8Ml0pAzBHKdM5qXPttYNy69eNV rSec4MT10eMW6NuFnEitB/qfIN9MK30uoGeJx5t/Re5B3dJD+PK2B1o+aNYKtsz3iQwK tfr9QZD+12XVJ8xIco8CjEo2Vyxs4hMtfX+iFsD/umzCVTxizJ3VozN64Tg0Q+DTxyn7 Es7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=QAx0zzZBH3vJ3zYXTImqXKLwPTv5LFpuSZLAoB3gyh8=; fh=JvnuCcZUn94+E7USoGOLIIHqIKo2y09yrW6UirpnTsU=; b=jXvG/sECsq7E17BYwhjRzK03dJaevvtMJxZd/93duvEYITCvXzPdeefZlYT5r/Xkr+ YTxwA80pD7wFJesv5/5Kuv0X8jN2VkBBNxCKqgFZ+690FR3ymLkKyMbbNR5K6wfiXTsf Gchdz2ymbNmHG4qBfmy5vuVQF2dpWPKRFsE7AMHy6EB8+hZdfxyelNJP12cEgbL+1m1h 4zDDv+xPpnqMn0xGPlMFCbfVebgq7Mkbp31jjY6zIEvKXJjhGpMonKgJktdYPbeCr0eQ CWQarfymRvE1IovBp+7ohfL2WuQQq2JizDUa9Pfg3yKf9o4Yzbr5zwYpBb1dGyWPfci2 2F4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pj9BWCQn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc3-20020a17090325c300b001b891259eeasi673694plb.580.2023.07.06.00.10.33; Thu, 06 Jul 2023 00:10:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pj9BWCQn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233217AbjGFGa4 (ORCPT + 99 others); Thu, 6 Jul 2023 02:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232501AbjGFGaz (ORCPT ); Thu, 6 Jul 2023 02:30:55 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45B8E1B6 for ; Wed, 5 Jul 2023 23:30:54 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3142a9ff6d8so233295f8f.3 for ; Wed, 05 Jul 2023 23:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688625053; x=1691217053; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QAx0zzZBH3vJ3zYXTImqXKLwPTv5LFpuSZLAoB3gyh8=; b=pj9BWCQnSTyNUIepazWS9qHh3NCIvW6mOZA9WeObO+hlR3nDeFbM+35uynR+ieHB1t FABwwgmGB1MuWVNiuA10/Zu6jeImjWz1sVKN9jXK4yVtyJHZLKTS95xV6M6CiQRAOggR lgmyumJZbKHmamvi9GwK3ARK7zpj7jmaGc0RITjSH4iyifObRzhZZ0qR22ScO0gJb1+d xDaB0T6ur7hHHeAMUxNc1MEsvr0QXlDyy830XkNSfZPxKY1BLbX00Q3wKtFloVhWwOpp t2nr8Yvb5nfQpAGJ2hsI449g60MLLfafkPS8om+xYnESsN77py0wdmCiCK7ii8dniJHB mM0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688625053; x=1691217053; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QAx0zzZBH3vJ3zYXTImqXKLwPTv5LFpuSZLAoB3gyh8=; b=Gv0/MONAHHSGcaOGN+pvKI/NLVl/YxxTtBPG0vdmT4CdxpwrDn2Qm/w5ORdSLDOEFr ViFC6iHltji4o5JSOPQ/5QNRnlvCzpAwv3l9kMpxvZFbsnRxWqu2gxGl+MFNicipHCXS 1RQ41tW1GhvPtnfzZL16UpyDtJMCw5YTbEJHwCBex7O7C34wTgyQUAHHodZPLiheSOUO ks/BgKaELs8qt/WrkZleCzaJX4dh4zuIahCyUDW/iwkPX3ABbmUMXeTXjm/Gp7OEwLzL vDSd6+7Pm08FnTWGcnBdOr+WzvRR5w6+X/ua3zDCrlrfscCKDpERp7AemsivlcQItom0 COyA== X-Gm-Message-State: ABy/qLa4tzHHJU+nqokHQZFSzA5+jnZq58XmWJZSr6ZDzMfinNY3WaeK 0NZT+FZEqGo34mL2e73WOZJl7w== X-Received: by 2002:adf:f60b:0:b0:314:50b4:c3c with SMTP id t11-20020adff60b000000b0031450b40c3cmr604098wrp.71.1688625052744; Wed, 05 Jul 2023 23:30:52 -0700 (PDT) Received: from [192.168.45.155] ([95.152.217.99]) by smtp.gmail.com with ESMTPSA id g3-20020a5d5543000000b0030e5bd253aasm942566wrw.39.2023.07.05.23.30.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 23:30:52 -0700 (PDT) Message-ID: Date: Thu, 6 Jul 2023 07:30:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: qemu-x86_64 booting with 8.0.0 stil see int3: when running LTP tracing testing. Content-Language: en-US To: "Richard W.M. Jones" , Peter Zijlstra Cc: Arnd Bergmann , Naresh Kamboju , Anders Roxell , =?UTF-8?Q?Daniel_D=c3=adaz?= , Benjamin Copeland , linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini References: <2d7595b1-b655-4425-85d3-423801bce644@app.fastmail.com> <20230621160655.GL2053369@hirez.programming.kicks-ass.net> <20230704074620.GA17440@redhat.com> <20230705162830.GC17440@redhat.com> <20230705215008.GD17440@redhat.com> From: Richard Henderson In-Reply-To: <20230705215008.GD17440@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/5/23 22:50, Richard W.M. Jones wrote: > tb_invalidate_phys_range_fast() *is* called, and we end up calling > tb_invalidate_phys_page_range__locked -> > tb_phys_invalidate__locked -> > do_tb_phys_invalidate > > Nevertheless the old TB (containing the call to the int3 helper) is > still called after the code has been replaced with a NOP. > > Of course there are 4 MTTCG threads so maybe another thread is in the > middle of executing the same TB when it gets invalidated. Yes. > tb_invalidate_phys_page_range__locked goes to some effort to check if > the current TB is being invalidated and restart the TB, but as far as > I can see the test can only work for the current core, and won't > restart the TB on other cores. Yes. The assumption with any of these sorts of races is that it is "as if" the other thread has already passed the location of the write within that block. But by the time this thread has finished do_tb_phys_invalidate, any other thread cannot execute the same block *again*. There's a race here, and now that I think about it, there's been mail about it in the past: https://lore.kernel.org/qemu-devel/cebad06c-48f2-6dbd-6d7f-3a3cf5aebbe3@linaro.org/ We take care of the same race for user-only in translator_access, by ensuring that each translated page is read-only *before* performing the read for translation. But for system mode we grab the page locks *after* the reads. Which means there's a race. The email above describes the race pretty clearly, with a new TB being generated before the write is even complete. It'll be non-trivial fixing this, because not only do we need to grab the lock earlier, there are ordering issues for a TB that spans two pages, in that one must grab the two locks in the correct order lest we deadlock. r~