Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1powkJ-0000c3-Cp for mharc-qemu-riscv@gnu.org; Tue, 18 Apr 2023 21:36:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1powkG-0000bU-SP; Tue, 18 Apr 2023 21:36:28 -0400 Received: from out30-110.freemail.mail.aliyun.com ([115.124.30.110]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1powkE-0005f4-Ch; Tue, 18 Apr 2023 21:36:28 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R731e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=zhiwei_liu@linux.alibaba.com; NM=1; PH=DS; RN=10; SR=0; TI=SMTPD_---0VgSNxxt_1681868173; Received: from 30.221.97.146(mailfrom:zhiwei_liu@linux.alibaba.com fp:SMTPD_---0VgSNxxt_1681868173) by smtp.aliyun-inc.com; Wed, 19 Apr 2023 09:36:14 +0800 Message-ID: <2f983083-025e-30d1-cb72-e1e256a3fe46@linux.alibaba.com> Date: Wed, 19 Apr 2023 09:36:10 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 6/8] accel/tcg: Uncache the host address for instruction fetch when tlb size < 1 Content-Language: en-US To: Weiwei Li , qemu-riscv@nongnu.org, qemu-devel@nongnu.org Cc: palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, dbarboza@ventanamicro.com, richard.henderson@linaro.org, wangjunqiang@iscas.ac.cn, lazyparser@gmail.com References: <20230418140632.53166-1-liweiwei@iscas.ac.cn> <20230418140632.53166-7-liweiwei@iscas.ac.cn> From: LIU Zhiwei In-Reply-To: <20230418140632.53166-7-liweiwei@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=115.124.30.110; envelope-from=zhiwei_liu@linux.alibaba.com; helo=out30-110.freemail.mail.aliyun.com X-Spam_score_int: -124 X-Spam_score: -12.5 X-Spam_bar: ------------ X-Spam_report: (-12.5 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, NICE_REPLY_A=-2.597, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2023 01:36:29 -0000 On 2023/4/18 22:06, Weiwei Li wrote: > When PMP entry overlap part of the page, we'll set the tlb_size to 1, which > will make the address in tlb entry set with TLB_INVALID_MASK, and the next > access will again go through tlb_fill.However, this way will not work in > tb_gen_code() => get_page_addr_code_hostp(): the TLB host address will be > cached, and the following instructions can use this host address directly > which may lead to the bypass of PMP related check. We can add a link to the issue in the commit message, https://gitlab.com/qemu-project/qemu/-/issues/1542 Reviewed-by: LIU Zhiwei Zhiwei > > Signed-off-by: Weiwei Li > Signed-off-by: Junqiang Wang > --- > accel/tcg/cputlb.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c > index e984a98dc4..efa0cb67c9 100644 > --- a/accel/tcg/cputlb.c > +++ b/accel/tcg/cputlb.c > @@ -1696,6 +1696,11 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, > if (p == NULL) { > return -1; > } > + > + if (full->lg_page_size < TARGET_PAGE_BITS) { > + return -1; > + } > + > if (hostp) { > *hostp = p; > }