From patchwork Wed Oct 16 20:09:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835835 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp618222wru; Wed, 16 Oct 2024 13:12:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVsILAe0FuCsr6B0AcE4oOyGIsiKg1dO7IOBMTczPCX+WhDq6YnqL71exPEhrjpx7hJCqex5w==@linaro.org X-Google-Smtp-Source: AGHT+IE0cTVQ09TXMTmBPlBDpSDu4u7k2XC78L7JrGuwBmJ0d9uohOHElradT11khpdEobQ6d4x0 X-Received: by 2002:a05:622a:1aa5:b0:458:4187:6eb8 with SMTP id d75a77b69052e-4608a5164bemr67397161cf.55.1729109532838; Wed, 16 Oct 2024 13:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109532; cv=none; d=google.com; s=arc-20240605; b=K+cv0cJGRxClnCSfazOwVx8R81cNQBSC5bX9X6N7d3aF/ypRl4X8Q2snCgbA4/kdCl d7zJEfSH0jP6nCHEldg6S5xps6YPAV/fRxBHFPfh38AgmZupUCw4AjlR1UpbUXGNZ56B rx/x6iU3DyOOkhyKCPf9G3XoX/7r5sZ0ocXdwL2DNSFFTSZctqgaocmKJnc5rciJCqss BzEbRmdrctXlB7bBG64oZkbAyeMlgXJbd6cj2ibYInPYKDmkB3XFISxZ0TmlRua2x6mL qqibyhnJqA8ZKOrmuPk87bGJNMhtwcLP2Mb8R88w6eK37/Ay1FSQXQcyHCmaJpPT5FQ7 /LKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=q5cja5O9iin9sQVMLagX4qLP+vP2dshgTKBh5SH9ezo=; fh=UbSczJHoK8QyPNwfbKMWepRwzNWZsm+gkdUzUXKForo=; b=JOM0t+CLSt/h+7Ll+2YjdIAvUbDzSE3J5ZjbjYlUeWUojll8fca3Z43k+/N4vRd7H/ dbcGwjLNbnJEQqqj1V5/DT2iEvvJD6oLCN4d1HllWJVJaT+qVvc9pTT9JY7b8frk2f85 fefGM34ctAOFjUUemSkrvySW2mvEOuAsMreTXFjsjMb/17mPpR+rmmEjVYakvrCSNhhM /gucftXzfEvyvq3v6CNOGqiwwgsyUyjEE6Xg8J/8NMUYZYZ1CRV8ZWraqeSqFYg1dkQN JbKrB71/bsNFDMqBa3zaYQfkQardGyAisFatURJv9Gr87Gp0DcwSvsW2NGeebmGGSdfF yK0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4607b4e5410si44116861cf.672.2024.10.16.13.12.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:12:12 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1ALy-0004ki-HO; Wed, 16 Oct 2024 16:10:42 -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 1t1ALx-0004kW-GI; Wed, 16 Oct 2024 16:10:41 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1ALv-0000ef-G7; Wed, 16 Oct 2024 16:10:41 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 5E28198F93; Wed, 16 Oct 2024 23:10:05 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 4376C156373; Wed, 16 Oct 2024 23:10:25 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Michael Tokarev Subject: [Stable-9.1.1 33/49] linux-user/flatload: Take mmap_lock in load_flt_binary() Date: Wed, 16 Oct 2024 23:09:52 +0300 Message-Id: <20241016201025.256294-1-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé load_flt_binary() calls load_flat_file() -> page_set_flags(). page_set_flags() must be called with the mmap_lock held, otherwise it aborts: $ qemu-arm -L stm32/lib/ stm32/bin/busybox qemu-arm: ../accel/tcg/user-exec.c:505: page_set_flags: Assertion `have_mmap_lock()' failed. Aborted (core dumped) Fix by taking the lock in load_flt_binary(). Fixes: fbd3c4cff6 ("linux-user/arm: Mark the commpage executable") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2525 Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-ID: <20240822095045.72643-3-philmd@linaro.org> Signed-off-by: Richard Henderson (cherry picked from commit a9ee641bd46f5462eeed183ac3c3760bddfc2600) Signed-off-by: Michael Tokarev diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 04d8138d12..0e4be5bf44 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -487,7 +487,10 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) stack_len += (bprm->envc + 1) * 4; /* the envp array */ + mmap_lock(); res = load_flat_file(bprm, libinfo, 0, &stack_len); + mmap_unlock(); + if (is_error(res)) { return res; } From patchwork Wed Oct 16 20:09:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835836 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp618472wru; Wed, 16 Oct 2024 13:12:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWBoCCAfJ7SCK1lW1aZ6ucP7Pz9CPrcHNF/03XiQXS2hOvcGPXvC1AgD4uvxIycsy2xX6ArvA==@linaro.org X-Google-Smtp-Source: AGHT+IFGSXkM9ClrFc9IvrmjQpqbUl+6EOlg97e2fv9yrPTh/BAh1HbSGfix/xxh1Wyd7ikQ71nx X-Received: by 2002:a05:620a:4151:b0:7ac:b197:2361 with SMTP id af79cd13be357-7b121008a56mr2554640885a.47.1729109571217; Wed, 16 Oct 2024 13:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109571; cv=none; d=google.com; s=arc-20240605; b=Egq3E56Ob1eLmYTz0PZbjlfXgn+4nbhTwI/ml9Hsv8X6nddEucqm2pjkPSy87W3GnF gdm0EKEyj6dBFClJ/VkTt48ZzhFYtUyDoy3PGRGvFZfczdoHmerz14mTr6TSxUyJF3L/ 3B3xYNShxA2ANCTIykPlKczH/LNjjhWFYpMPHjUyDqKhBK5amIMLBMmFcV0s5S4UFA+A om1cYLyRz24IGZMbKKQc4jORuUtQn1R3eb/fWOpBHAf5MpJ8RcvPOo6a9xvoCrQ5lQrV Jv3RlAKBWFEuHPXIOM0YHe6IUzLR5knpsbzdalKTiaEFYgnzuP3fSra/ISpq8l+jG18z Svqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=BLRtFvXZ6MSz9tSJJBCQJWFbuwJINWOaCht8rBeIAm8=; fh=K4abbxCgZAPvqzOXA+PZ7RIZh+KufMVJze7rXLOwES0=; b=EJeOfodET2LkfKCm/dwfmPczpzSkc1a+4oX/+YbzBgfursk+ECWfm2ASDCTLTudNLi ozNFErg8IDVqrj2ktpJAvl/4fDoTq0PrWf7lDrgNDBCN5h1B9PP2aqxvFPio+vU5TgUz rzfRnAGEldkFrKGAYjHwjVRzKp7nuY26PyJKzsKo5JZvTS8eVnp5yC/6aUkyFFi6TkJQ 5JVJsBSZL4BXmjlTLoOodGZX95WolYvHWJBnHjsgKz0h3MzxtKn81W2ngUTwgNVtneTn P43iAAPS0Z3PW4g/q0vnmkFjbkUek6eC/fnXAjY2VY4zPNpWbgiUmTRNsaVHCcE+Jinu zG+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4607b0fa04bsi48531751cf.33.2024.10.16.13.12.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:12:51 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1AM0-0004lX-0y; Wed, 16 Oct 2024 16:10:44 -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 1t1ALy-0004kj-NH; Wed, 16 Oct 2024 16:10:42 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1ALw-0000fL-TV; Wed, 16 Oct 2024 16:10:42 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id BEB8198F94; Wed, 16 Oct 2024 23:10:05 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id A4F52156374; Wed, 16 Oct 2024 23:10:25 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-9.1.1 34/49] linux-user: Fix parse_elf_properties GNU0_MAGIC check Date: Wed, 16 Oct 2024 23:09:53 +0300 Message-Id: <20241016201025.256294-2-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Comparing a string of 4 bytes only works in little-endian. Adjust bulk bswap to only apply to the note payload. Perform swapping of the note header manually; the magic is defined so that it does not need a runtime swap. Fixes: 83f990eb5adb ("linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2596 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael Tokarev (cherry picked from commit 2884596f5f385b5712c356310dd4125a089888a8) Signed-off-by: Michael Tokarev diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b27dd01734..0b1c230b1c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3136,11 +3136,11 @@ static bool parse_elf_properties(const ImageSource *src, } /* - * The contents of a valid PT_GNU_PROPERTY is a sequence - * of uint32_t -- swap them all now. + * The contents of a valid PT_GNU_PROPERTY is a sequence of uint32_t. + * Swap most of them now, beyond the header and namesz. */ #ifdef BSWAP_NEEDED - for (int i = 0; i < n / 4; i++) { + for (int i = 4; i < n / 4; i++) { bswap32s(note.data + i); } #endif @@ -3150,15 +3150,15 @@ static bool parse_elf_properties(const ImageSource *src, * immediately follows nhdr and is thus at the 4th word. Further, all * of the inputs to the kernel's round_up are multiples of 4. */ - if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 || - note.nhdr.n_namesz != NOTE_NAME_SZ || + if (tswap32(note.nhdr.n_type) != NT_GNU_PROPERTY_TYPE_0 || + tswap32(note.nhdr.n_namesz) != NOTE_NAME_SZ || note.data[3] != GNU0_MAGIC) { error_setg(errp, "Invalid note in PT_GNU_PROPERTY"); return false; } off = sizeof(note.nhdr) + NOTE_NAME_SZ; - datasz = note.nhdr.n_descsz + off; + datasz = tswap32(note.nhdr.n_descsz) + off; if (datasz > n) { error_setg(errp, "Invalid note size in PT_GNU_PROPERTY"); return false; From patchwork Wed Oct 16 20:09:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835838 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp618821wru; Wed, 16 Oct 2024 13:13:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPrixNq43IbBWBpNrgMCWzyfhdquwgCQyxOJRYhjuOCL5Dp1SImKmsj+5X4yq6RWD7Uy8uvw==@linaro.org X-Google-Smtp-Source: AGHT+IFWKF761D56d9MVF4x/+EZ6tEuVFDrrBT+rXbQ4hx2Mi9pjB37NcQLkoS/UeA6uoBv5J/zn X-Received: by 2002:a05:620a:24d4:b0:7b1:49f7:90c2 with SMTP id af79cd13be357-7b149f7939cmr310556685a.26.1729109627790; Wed, 16 Oct 2024 13:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109627; cv=none; d=google.com; s=arc-20240605; b=b9m+OJu5co5qfYIpmJzJhrxVA5UkMWWn+SPft+tDHv84LpwnbGjAzF79sxUBqj4YZB T2q1EYxMEYqmYnoagomJ/Wagvi3F2S/Q1h9HlPsGUSFBDI8sfwVVzjoiO+U698OMOwFI QMZ9q6wH8Q+NklwS2GajCKD9hv3Q36A6YWyna6THxIMAoBDghUTzD0yKblcKCPF94mqQ 0Mq10ClXkhbQgmAX+c+5uDIFQQbfHYfEaI5xViBBr5/a2sZvAmhmFsxQx6qaL2Hxug9x 9lcxrUp5XZib6Lf6HuTLGiPXQ/iQEo5vRoeWRcOIFzPGUuDnoYUig6zQSmlTJGvT8Qsn i00A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=0VYY9xOyVPfkAU9T4OwMt83yWBMxMR1kkt4Cun5Q2sk=; fh=bMaafE1clBtiBaCrlbrbcY1DSEPhhFUklUk4XoVHiPU=; b=NYiYqNaS9A/RP7cS/KyWTh6aEEgC9IaTGeg0bSytXdY0TFvu3NMrYfxs2W26eE+L9t bpk+DkWjHEVefA6ckT6pHSPBF/XwhUg6OJk36bFLJ7tkE2UeGYu9j9wf4NVWqV6TisTl mOXpJMsyS5S5GEr5PSr/4QznM3eIXT1zeH5JHLPnC0H+0n/6NoCRaIFH7QYWm5Z1bQoY eqntj0K88Q257pVcLz5yLYr2pEpdCzSA7qEqTeFR7KAKFYTT94Dj30NG2LbAPGwpqf0p 7UknTSQ2swPVPDlazw7fq5ne53NSMUt0QaQEaa+NZPOk3gX8I1Si4wt5WMaz6+UfymXd dX2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b1363752edsi449153485a.134.2024.10.16.13.13.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:13:47 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1AM2-0004mZ-H7; Wed, 16 Oct 2024 16:10:46 -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 1t1AM0-0004m3-IY; Wed, 16 Oct 2024 16:10:44 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1ALy-0000fe-UO; Wed, 16 Oct 2024 16:10:44 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 1DDA398F95; Wed, 16 Oct 2024 23:10:06 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 121D5156375; Wed, 16 Oct 2024 23:10:26 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Michael Tokarev Subject: [Stable-9.1.1 35/49] tcg/ppc: Use TCG_REG_TMP2 for scratch tcg_out_qemu_st Date: Wed, 16 Oct 2024 23:09:54 +0300 Message-Id: <20241016201025.256294-3-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson In the fallback when STDBRX is not available, avoid clobbering TCG_REG_TMP1, which might be h.base, which is still in use. Use TCG_REG_TMP2 instead. Cc: qemu-stable@nongnu.org Fixes: 01a112e2e9 ("tcg/ppc: Reorg tcg_out_tlb_read") Signed-off-by: Richard Henderson Tested-By: Michael Tokarev (cherry picked from commit 4cabcb89b101942346aebff081aa1453e958fe7f) Signed-off-by: Michael Tokarev diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 3553a47ba9..69abd30bbb 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2704,9 +2704,9 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg datalo, TCGReg datahi, uint32_t insn = qemu_stx_opc[opc & (MO_BSWAP | MO_SIZE)]; if (!have_isa_2_06 && insn == STDBRX) { tcg_out32(s, STWBRX | SAB(datalo, h.base, h.index)); - tcg_out32(s, ADDI | TAI(TCG_REG_TMP1, h.index, 4)); + tcg_out32(s, ADDI | TAI(TCG_REG_TMP2, h.index, 4)); tcg_out_shri64(s, TCG_REG_R0, datalo, 32); - tcg_out32(s, STWBRX | SAB(TCG_REG_R0, h.base, TCG_REG_TMP1)); + tcg_out32(s, STWBRX | SAB(TCG_REG_R0, h.base, TCG_REG_TMP2)); } else { tcg_out32(s, insn | SAB(datalo, h.base, h.index)); } From patchwork Wed Oct 16 20:09:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835834 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp617953wru; Wed, 16 Oct 2024 13:11:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWtYGUH9prq+JTyUWvPeIvzf7RC4m2oK0rfL9rjxPArHafEg+xo55sb6mq5MFUEPP5m5ZMuGw==@linaro.org X-Google-Smtp-Source: AGHT+IGTnP8ixKERaLPPzYNRxwC7fntYSUBpra/cQ1aSG9ZtOuTHb/+PZqNxX9quTfuClnY8UOkc X-Received: by 2002:a05:622a:11d5:b0:460:7b38:9000 with SMTP id d75a77b69052e-4608a4b0a66mr76791161cf.11.1729109491513; Wed, 16 Oct 2024 13:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109491; cv=none; d=google.com; s=arc-20240605; b=P/0mgHLxqO86hH+j4FCMmf9hBHDYsy9MIe4xc6dT/kviO922V40YW2oTTArEdAK99W +a/SyWioDUaki64Vf3h9DYHhbdD3Pn0GFxGN1itf4FV5FNN1L3bNVcTEdbSdm/+V1QpH llR2y3dH3X+C8hMC0AWZYseuSTsWbWDSUPtplOVk7lRyEcsy1bGE0VqNG6CCOBjv9+/K kuLRoEAgV2QfiBifbqUezZQKhwoyvoFGfAj2HjUBCjqbAKnH94c8Xyvhrtubf8gxxql2 gxXVzP3XhOYgWULgWYV4aUxcRFaOTWFS79vbXNAyOABvkpBp/PI/KxkQie7t5ccaXZfu UHIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=qW0FM7/1Hsw9oSOFRBqGMBwC4og+NOyg19A3CZh9maU=; fh=bMaafE1clBtiBaCrlbrbcY1DSEPhhFUklUk4XoVHiPU=; b=Rp/x1Eafhy99dC++4NZ4EjJSi7+PLVwtmLQUFntoN8i+OzcPZfs+GsD91LHhRFvkEo dHwHMTUcq/uTbTeWS05/z7w0kkBPw0fFkqPO2LeQCk5fN5teRXlWvJGIL94p0RHkTJ5/ xvUaQ6mft96EC9FTrkeYYSCIR3ZX/NVP7uLmN/PZlrbnv60hULt8OxORfyzU0yDwUxyJ rcjW0xmkXX5lXkSmhc6Did0UHahOb0Wagmc0iYyXsmrfLDlQx6+Ag6JJXq37lg+MSvCP gFaf7byd8Xq7jom7I+/YeuCe3hNJQHuoMfaKXA18S9pQbGweeeX6k8wP5NBKLZ+e/NC4 XS1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4607f2e46b6si43158491cf.735.2024.10.16.13.11.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:11:31 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1AM3-0004nd-Np; Wed, 16 Oct 2024 16:10:47 -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 1t1AM2-0004mO-3E; Wed, 16 Oct 2024 16:10:46 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1AM0-0000fu-G7; Wed, 16 Oct 2024 16:10:45 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 785A398F96; Wed, 16 Oct 2024 23:10:06 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 63EF1156376; Wed, 16 Oct 2024 23:10:26 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Michael Tokarev Subject: [Stable-9.1.1 36/49] tcg/ppc: Use TCG_REG_TMP2 for scratch index in prepare_host_addr Date: Wed, 16 Oct 2024 23:09:55 +0300 Message-Id: <20241016201025.256294-4-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson In tcg_out_qemu_ldst_i128, we need a non-zero index register, which we then use as a base register in several address modes. Since we always have TCG_REG_TMP2 available, use that. Cc: qemu-stable@nongnu.org Fixes: 526cd4ec01f ("tcg/ppc: Support 128-bit load/store") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2597 Signed-off-by: Richard Henderson Tested-By: Michael Tokarev (cherry picked from commit 3213da7b9539581c6df95f8ced5b09d0b02d425f) Signed-off-by: Michael Tokarev diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 69abd30bbb..deb80521b3 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2617,8 +2617,8 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, if (TCG_TARGET_REG_BITS == 64 && addr_type == TCG_TYPE_I32) { /* Zero-extend the guest address for use in the host address. */ - tcg_out_ext32u(s, TCG_REG_R0, addrlo); - h->index = TCG_REG_R0; + tcg_out_ext32u(s, TCG_REG_TMP2, addrlo); + h->index = TCG_REG_TMP2; } else { h->index = addrlo; } From patchwork Wed Oct 16 20:09:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835833 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp617877wru; Wed, 16 Oct 2024 13:11:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXWisYCREUK3/FLQoYwyDneWkQqp9Rpaj2FbMJ4my7LEywcYRW50cEbqYkSHXUsEu8fLAigKw==@linaro.org X-Google-Smtp-Source: AGHT+IGKNgnJ3iOZm4aRVSgY1Hbe8uZtoTrOV0J2IQju7gKXOJo0DS8zrbXqUvhyCevxy223Tjz0 X-Received: by 2002:a05:6902:120c:b0:e1d:c3ea:da04 with SMTP id 3f1490d57ef6-e29782decbcmr5666456276.13.1729109482443; Wed, 16 Oct 2024 13:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109482; cv=none; d=google.com; s=arc-20240605; b=BZOPaTwwqlQpoeTOkyQ0cARjs5GPURWLO40vEc6lCniuzp1RLpUxW5rSKCYq6qpzLv nhDct11OalOrC6HoOBIyFUPACB440e2qnoAUERI0fW/RU3h83jUM+mTpNKClxhyW1PxI 7UjvAd6bMGCU46lAyRrr70erJPNt8vxZU9KmgXn29j0PIBNlClzsn3C6YOMpEwBbkQtq mev/p4O6sBJ/K1DCqLnCuacE1G3ByOU3Btqj482awpP5YhBtidc3ARjVAIUODj+0scDt ULfYeRxQTo7ZtII8SNshsBLYa9bMhrkU4VYKA4QiAsxwD2runTe0zPR3mjYc9kK7JoUz vssg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=T5JV9itkvMKHg0ojdZt9nD23K79kpzLgfdPFAW/dfiE=; fh=K4abbxCgZAPvqzOXA+PZ7RIZh+KufMVJze7rXLOwES0=; b=IkeiUsqJxBboNOPQiCpLI0zKHsv3wZ3dJVyyIwFULTDo5Uk1e4FouL/E/DJXSIEfLN hbQVcnwguhUtXzfbN01iBm148Tf0qI16buZTyB3G5x5279pwPSJAdHMnuvMXEhsliQzf G3C+EiDw9vIKb/Zv011ZkF/NIVFRPeRpPY57okqW3m5USEX0ozp91fGU7jg/v+5YWc3T 2SeO1/xWd1obFwsrWOIcoKnjMG67y71hZ1B6DTmZCxTTsVyQc52nQugLRaidRiGyWalF Ai4ULZh0k7n0ScNDxIpP6+CvCGrZ8ThYKnwhdxUn3izaSd7R616yZdoVKDsIYu+dYORm L8Lg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4608e68f90dsi24161751cf.431.2024.10.16.13.11.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:11:22 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1AM5-0004o6-7H; Wed, 16 Oct 2024 16:10:49 -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 1t1AM3-0004nc-Iu; Wed, 16 Oct 2024 16:10:47 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1AM1-0000g9-Ua; Wed, 16 Oct 2024 16:10:47 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id D2CC298F97; Wed, 16 Oct 2024 23:10:06 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id BED0C156377; Wed, 16 Oct 2024 23:10:26 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-9.1.1 37/49] target/m68k: Always return a temporary from gen_lea_mode Date: Wed, 16 Oct 2024 23:09:56 +0300 Message-Id: <20241016201025.256294-5-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Returning a raw areg does not preserve the value if the areg is subsequently modified. Fixes, e.g. "jsr (sp)", where the return address is pushed before the branch. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2483 Signed-off-by: Richard Henderson Message-Id: <20240813000737.228470-1-richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé (cherry picked from commit 352cc9f300d83ea48b8154bfd2ff985fece887d0) Signed-off-by: Michael Tokarev diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 445966fb6a..ad3ce34501 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -720,7 +720,9 @@ static TCGv gen_lea_mode(CPUM68KState *env, DisasContext *s, } /* fallthru */ case 2: /* Indirect register */ - return get_areg(s, reg0); + tmp = tcg_temp_new(); + tcg_gen_mov_i32(tmp, get_areg(s, reg0)); + return tmp; case 4: /* Indirect predecrememnt. */ if (opsize == OS_UNSIZED) { return NULL_QREG; @@ -747,20 +749,23 @@ static TCGv gen_lea_mode(CPUM68KState *env, DisasContext *s, switch (reg0) { case 0: /* Absolute short. */ offset = (int16_t)read_im16(env, s); - return tcg_constant_i32(offset); + break; case 1: /* Absolute long. */ offset = read_im32(env, s); - return tcg_constant_i32(offset); + break; case 2: /* pc displacement */ offset = s->pc; offset += (int16_t)read_im16(env, s); - return tcg_constant_i32(offset); + break; case 3: /* pc index+displacement. */ return gen_lea_indexed(env, s, NULL_QREG); case 4: /* Immediate. */ default: return NULL_QREG; } + tmp = tcg_temp_new(); + tcg_gen_movi_i32(tmp, offset); + return tmp; } /* Should never happen. */ return NULL_QREG; From patchwork Wed Oct 16 20:09:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835837 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp618718wru; Wed, 16 Oct 2024 13:13:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHT2xYWaAYMrTdCf2ohDI32q1Q7Yram0K5IJgfjhW4SDZqbM6wL4ZfbGx0hqYD5VuziOybBQ==@linaro.org X-Google-Smtp-Source: AGHT+IFTFTa1+Jyr1S3ETsSEMMZIloBGLWNlLlD0+houZtM2e2YT1WyZfenHDXe82XYLiGWple7m X-Received: by 2002:a05:620a:24c7:b0:7b1:4276:ea4e with SMTP id af79cd13be357-7b14276eb46mr615939085a.13.1729109613269; Wed, 16 Oct 2024 13:13:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109613; cv=none; d=google.com; s=arc-20240605; b=exY5X+Oz0zhiLCwhdBKS1DiqwDm2dKq16DFSrjxq/92yXDhjvJsjodznyrjeWgJmLz hsQ6mVbGIEoRJdBOcGIwUAMicCw0O577zGMA83tY1gB2dx0v7/QJxTSoqYfG0Q1EB2Lj ZHDuPyEOwqvXjctq1eBw0VU66ST7uxoAdVyvLAxU5lQE1CNzPsaTl5kbdCaIi8ch2NeV H4u98dX7vjIUxaFLq20krzhGh+ZZdYkOqkJuUSa8M5ejnx4B+eQQayGd69bzW0BF7wKv NPS9zXEZLHQEY/e2gZQ+HpYsXM0IQGZlcSYYYJc0OV42aSe20G6/50wo05ZIw2BwsIfM O1uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=kfP/69WgcAfN9mkt4p7M/It7exi9c9CInp6h/Sw2mlw=; fh=KVtYRd30R01aSPO7CMjJBRFyHkwXLtpuZP0IBHPiisw=; b=Za+ny7B92hDDg1GbF9hcKBoc7gmwSKcXUYxx+aO0BOEbBJ8dkYMvVatbMy93KMmSC6 6r/MoZwzBti1R+2DKmMPX2bjSTsRpDjyccHCmMRe58k0bqU5jsZf+yU9TapzQs8d08ye qtzZoruE2SK+xb56zoGnqm5GAHoq26RvcxrBiPF22fAKuOEysI9J2+dvQpVUNmcISW/F Qgk46tROCo/akKsqqCgbHIC9ZT7+50Dv88z5XUwjMXiY57kVk9Bke6IlCX3EWm0JzB9Z 8aXJjfJ0jEiyXPTEcXkZpy3UhYPLmWFow4Zhqqc7eLJoXSRczJswRjHgi31vyzGLdYcY mcQA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b14f204dccsi24081585a.480.2024.10.16.13.13.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:13:33 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1AM6-0004pB-Rf; Wed, 16 Oct 2024 16:10:51 -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 1t1AM5-0004o7-6A; Wed, 16 Oct 2024 16:10:49 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1AM3-0000gN-Hd; Wed, 16 Oct 2024 16:10:48 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 4566998F98; Wed, 16 Oct 2024 23:10:07 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 260E9156378; Wed, 16 Oct 2024 23:10:27 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= , Michael Tokarev , Paolo Bonzini Subject: [Stable-9.1.1 38/49] meson: fix machine option for x86_version Date: Wed, 16 Oct 2024 23:09:57 +0300 Message-Id: <20241016201025.256294-6-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier s/mbmi1/mbmi/ When configuring with -Dx86_version >= 3, meson step works, but compilation fails because option -mbmi1 is unknown. Signed-off-by: Pierrick Bouvier Reviewed-by: Alex Bennée Tested-by: Alex Bennée Link: https://lore.kernel.org/r/20241004223715.1275428-1-pierrick.bouvier@linaro.org Cc: qemu-stable@nongnu.org Fixes: ef7d1adfa85 ("meson: allow configuring the x86-64 baseline", 2024-06-28) Revieved-by: Michael Tokarev Signed-off-by: Paolo Bonzini (cherry picked from commit 461a9252e249adab5f0bae3b9634be77dd5be17e) Signed-off-by: Michael Tokarev diff --git a/meson.build b/meson.build index fbda17c987..6e467cbe7d 100644 --- a/meson.build +++ b/meson.build @@ -362,7 +362,7 @@ if host_arch in ['i386', 'x86_64'] qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags endif if get_option('x86_version') >= '3' - qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags + qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags endif # add required vector instruction set (each level implies those below) From patchwork Wed Oct 16 20:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 835839 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp619145wru; Wed, 16 Oct 2024 13:14:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDkW+mOndf/TNsdpr3KhOmOS4pZI3++mOJ3jR9knQQdTY5gGWKnhRJsXbJJzom0BrWkt+3og==@linaro.org X-Google-Smtp-Source: AGHT+IEAJ7998aykCEVQctrtamKkdiveafp3Wv1duimCePXEk3hpTtF3Y8Iy0KSSsIbTTmMSrFAB X-Received: by 2002:a05:620a:2453:b0:7b1:4823:fa84 with SMTP id af79cd13be357-7b14823fc67mr391785285a.16.1729109690034; Wed, 16 Oct 2024 13:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729109690; cv=none; d=google.com; s=arc-20240605; b=E0nA3z92lbvB7F7MKHUM7Hpfhjm0kMQocuqmdyIGodLwY+7IMJQpdwqsbB/3GRQQDK K6XcVeJ2g2mvgmA6YoenuC3FQsJiEJitJIRtq4UvBSBorY/w162Y9Om4ADam0l2V3qu8 IfsmXM8nkbpWoP4Azn6JImOIHhN5zRiQDr42AwWuFccKqeN+WPWr/BXII/EqzT+khxP5 l91eEeZVz2Bd+8ReCQQ8WlocG4GjXgBVsSge6b/Jq2nze0IvxboYyzjNDtksm/1FrlI8 CR0JiZs4RIiZAN49YFSPOQChV1JoGWLFI/KRiH/dMKTNssIjeNc0OyFNHoxiYcNmziHO FM6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from; bh=klg8c78RobC5e0uhuAaMWdowdfYEGfTv6D9vxLih0jw=; fh=y/le4EldSTqzlVgVqeuX3gsPwkWjr7n6va7+csfsCRw=; b=YD2LRrQRp/7CPI8dO5iTFLy8PESHm7vTgbI4sJW+LmIpzO0r0pNsLdHYHuH6xIXPLZ hWvyBmo79UVWv11Yp6QBMVNWkOdKTyc+Oo7QefNkqzaJqqpAb0Ht/0BaTWOyBGuT2Ozk UIEukGWDXBs7fKBGoDklR7fgIyMIb9eOBWGUji1xCKvYOre2xUU0+s4AwTDGL48Vz+Dg D6fIuf1aN0tC9rUijqFtnH5KAWQL/ftqXl+WlclKkzaAzX9oHEYH61VzldvFOhmlcRNG njYkThClkt4m0Dj4kS91TYmOxOJQd8YwwAcE0ASQSbOaMmduJiY2HaeCdtotp9vjo5Ji C8Hg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b143c31d3csi276969785a.191.2024.10.16.13.14.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Oct 2024 13:14:50 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1AMb-0004zY-BP; Wed, 16 Oct 2024 16:11:24 -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 1t1AMY-0004yT-Gs; Wed, 16 Oct 2024 16:11:18 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1AMW-0000il-Ro; Wed, 16 Oct 2024 16:11:18 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id C6B2198F9E; Wed, 16 Oct 2024 23:10:09 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id A002815637E; Wed, 16 Oct 2024 23:10:29 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Gavin Shan , Michael Tokarev Subject: [Stable-9.1.1 44/49] hw/char/pl011: Use correct masks for IBRD and FBRD Date: Wed, 16 Oct 2024 23:10:03 +0300 Message-Id: <20241016201025.256294-12-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell In commit b88cfee90268cad we defined masks for the IBRD and FBRD integer and fractional baud rate divider registers, to prevent the guest from writing invalid values which could cause division-by-zero. Unfortunately we got the mask values the wrong way around: the FBRD register is six bits and the IBRD register is 16 bits, not vice-versa. You would only run into this bug if you programmed the UART to a baud rate of less than 9600, because for 9600 baud and above the IBRD value will fit into 6 bits, as per the table in https://developer.arm.com/documentation/ddi0183/g/programmers-model/register-descriptions/fractional-baud-rate-register--uartfbrd The only visible effects would be that the value read back from the register by the guest would be truncated, and we would print an incorrect baud rate in the debug logs. Cc: qemu-stable@nongnu.org Fixes: b88cfee90268 ("hw/char/pl011: Avoid division-by-zero in pl011_get_baudrate()") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2610 Signed-off-by: Peter Maydell Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Gavin Shan Message-id: 20241007144732.2491331-1-peter.maydell@linaro.org (cherry picked from commit cd247eae16ab1b9ce97fd34c000c1b883feeda45) Signed-off-by: Michael Tokarev diff --git a/hw/char/pl011.c b/hw/char/pl011.c index f8078aa216..949e9d0e0d 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -88,10 +88,10 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define CR_LBE (1 << 7) /* Integer Baud Rate Divider, UARTIBRD */ -#define IBRD_MASK 0x3f +#define IBRD_MASK 0xffff /* Fractional Baud Rate Divider, UARTFBRD */ -#define FBRD_MASK 0xffff +#define FBRD_MASK 0x3f static const unsigned char pl011_id_arm[8] = { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };