From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437751; cv=none; d=zohomail.com; s=zohoarc; b=PnEylAvQLocYsNV6im/ERmWo3wCS47bNTKijHPU0skaA1h4TqESR5kp9Xjp0R5IEoFU20w8XFmEFyroorWVmo5lUKoJzgVLkaA30oqcASVM55ZCTUQVAAsN6zk8tDV2BDr8byr0SPF27gaGvyzM3Y0cfqvaxEkLIIf9ctTAaUiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437751; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=dg0lyWp/iYHR0SwtBFKYV9jsMjYg3PofI7llGsLHSMo=; b=VxGzQeJ40/CGP/vEax72+qpVUT5ZTzw2p+3YV7HPTZMJPzpYjgYztzHW51tibORU/WSRMKna8cCgEy6kCR3FtHD54PLO2iDIBUGjxLh7websck/AKodaQ8ZruwIUcZFVD5UVaHXBtXSCPQLfPgfPM8Jj/i8fd7CE54W6oRqczY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437751338163.44287234675312; Fri, 20 Jun 2025 09:42:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSenZ-0006SJ-FO; Fri, 20 Jun 2025 12:41:05 -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 1uSenY-0006S3-0j for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenW-0000Dh-H2 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:03 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-5hRGvIxhPZO3mPkV87cNbw-1; Fri, 20 Jun 2025 12:41:00 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-6077833ae13so1591842a12.1 for ; Fri, 20 Jun 2025 09:40:59 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a18cba650sm1591266a12.55.2025.06.20.09.40.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dg0lyWp/iYHR0SwtBFKYV9jsMjYg3PofI7llGsLHSMo=; b=Ivse6f++J6dORJMzQ2RYxJJpO7LhAnKw7fQnT9bbQiy7V70XZQ+1V79AsAAZTjFR56G1C6 Q+9nRMSuxGQE4XzEV39WbROiLwXeGx72d3MrkvabKdZgHA/FPmEJ5G3yacWHr79peXooW9 ZB4538DTGcR1ePDawZ1aQPIzIlHPzX8= X-MC-Unique: 5hRGvIxhPZO3mPkV87cNbw-1 X-Mimecast-MFC-AGG-ID: 5hRGvIxhPZO3mPkV87cNbw_1750437659 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437658; x=1751042458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dg0lyWp/iYHR0SwtBFKYV9jsMjYg3PofI7llGsLHSMo=; b=R1VwaQ/l3DuyN8BqkTPWmJ2EBe6lw07t4M+f4oO4TAQQkrRIhhfEVXopl89jtCkjOY dR4RXcuW7w1CQXkGYw20gl/oZFshuPPoUZsaoMC8UDBsZYo/aoe0H0hoeBUOUlAHLB6w +6jgkCF/ezPn9mfcUg+mAKOgTcPSPK06hOW05qyOjYtfSSKgEtcg2XamRCVYc1DDeIzK 8J+SwED90tnDVlqMtN1aQU9SEYI6/I+6pzAEwwwOdf8dhNqB3YalMo72lN+HonZujEys C3g8t58DJYKBb9uhuE1wlipHmBdh++yNofpADzmluDKg5TA9vJ6kZZKnnpB6JesGq3Ng j3kQ== X-Gm-Message-State: AOJu0Yzgymvd0icox0gHFfOUNQYFBooDwALJrq5Hgfcn6E4osrNvHIRB 7y3HRCcxp6L4lXEt+Z1OkVToy36PI+pwK/EQxhZo22G30E8I9Rg0o6nZnP4luj/aYbLJ4Y+xSIp JAnocbapwvv7oPBf+7ljhOn5uoA0ik/ZZM3J+wA1WSDYMxcqoSlZKaJeyVzLnRhW8muWz/HuLj1 X7s5nhK68DO6U7bbNlAtnydow9bJKOJaUtf1UiyBUQ X-Gm-Gg: ASbGncuekzB70p2fR2YadSRYnZAjxFr3RHs9MLSxRNRLeuWu8rRzG58yqjmpK1Mstby i6Jv2NO2bwgzHuZfjakg9RxkKm5sWImkwSce9cvZzof7ecJa+8A4JsPUWY/j29higzENVwlRRYF VXQLl6L4zohYqfB2Gfa6DE4CHC2ksLLXSvaUAGANJy1dWGUpKUAZ6I5U6ZusJdPXdBhHlYTic5y 0dbqIdjVyyrB28XmjCbIt/DSOWsXbc5Pzkb8ObPr/sXWxXrdZ7TtuqHP2k5dwVcwq0wHi2gtEtH aNXeQuHXnIg2lRC5sMZ0KnEU7w== X-Received: by 2002:a05:6402:1e89:b0:604:f62b:4118 with SMTP id 4fb4d7f45d1cf-60a1cd1a88emr3115268a12.5.1750437657882; Fri, 20 Jun 2025 09:40:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm2Vv9lHQkXerKFiYB2TIpO23tiNUC8NS/3eSZHdis7Z++pIOlykAucgDZysigDUg15X+mfQ== X-Received: by 2002:a05:6402:1e89:b0:604:f62b:4118 with SMTP id 4fb4d7f45d1cf-60a1cd1a88emr3115246a12.5.1750437657375; Fri, 20 Jun 2025 09:40:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/24] meson: cleanup win32 library detection Date: Fri, 20 Jun 2025 18:40:29 +0200 Message-ID: <20250620164053.579416-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437753494116600 Content-Type: text/plain; charset="utf-8" As pointed out by Akihiko Odaki, all Win32 libraries in MinGW have lowercase names. This means that on (case-insensitive) Windows you can use the mixed= -case names suggested by Microsoft or all-lowercase names, while on Linux you nee= d to make them lowercase. QEMU was already using lowercase names, so there is no need to test the mixed-case name version of libSynchronization. Remove the unnecessary test and while at it make all the tests use "required: true". Signed-off-by: Paolo Bonzini --- meson.build | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 34729c2a3dd..ed60be2a2d0 100644 --- a/meson.build +++ b/meson.build @@ -843,15 +843,12 @@ host_dsosuf =3D '.so' if host_os =3D=3D 'windows' midl =3D find_program('midl', required: false) widl =3D find_program('widl', required: false) - pathcch =3D cc.find_library('pathcch') - synchronization =3D cc.find_library('Synchronization', required: false) - if not synchronization.found() - # The library name is lowercase on mingw - synchronization =3D cc.find_library('synchronization', required: true) - endif =20 - socket =3D cc.find_library('ws2_32') - winmm =3D cc.find_library('winmm') + # MinGW uses lowercase for library names + pathcch =3D cc.find_library('pathcch', required: true) + synchronization =3D cc.find_library('synchronization', required: true) + socket =3D cc.find_library('ws2_32', required: true) + winmm =3D cc.find_library('winmm', required: true) =20 win =3D import('windows') version_res =3D win.compile_resources('version.rc', --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437805; cv=none; d=zohomail.com; s=zohoarc; b=jAKGg+mSXybJfpF9BjDwRqNpYURdYbHxng/FzvwvaN864mzw5Yj5dOFfZskSxpJnoj84IgEJPakXgMopJd0ymfsbP5G9iJRmGHU3DtDrBMMxnuMsb/gh90NlNwiAyIrdLItkm3jSknmTZKBkw57jpXLcPAw49GcfhYOzh67KUZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437805; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aN7xXBZj4Ftx1dfcGboeMP703/cTHxafXoXtiLZOCMM=; b=dSYwbzxyfC/M1wtMzdy278vWYgWuj4uMizHaUYNMwm55hnl3tmNMrjl0AWgVuUByVCa84xG+VoiUyfdEACroqHiPGAWc89GjrJEHxssQqf2ey7XPdlFLHWoQq0/eL8+zbqJedpkasqpL3u0LRcxQSrubGLadoxNdwbjQMpaxiKM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437805179121.85940605050871; Fri, 20 Jun 2025 09:43:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeng-0006UK-DE; Fri, 20 Jun 2025 12:41:12 -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 1uSenf-0006U0-4j for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSend-0000EP-GF for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:10 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-42-AR6twZNIMkixfzurSRktig-1; Fri, 20 Jun 2025 12:41:02 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-606f504f228so1769228a12.3 for ; Fri, 20 Jun 2025 09:41:02 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a185797bbsm1629935a12.35.2025.06.20.09.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aN7xXBZj4Ftx1dfcGboeMP703/cTHxafXoXtiLZOCMM=; b=euvtBywRWLfNOPZfz317V1ZRRGCwNhbxNxJX5YsJoHAJwZVAudmNvcqZ+B90X4jwqUqiWe V8CHAQ9t9GjMSLwATNGQ9ggCgP+jBvvETgUGHgBcAw4Ddmw0rpQiqnnYrN1dByqEfBCx4v zN1SCXcWsn+zumyv0nZFERFzbIst61A= X-MC-Unique: AR6twZNIMkixfzurSRktig-1 X-Mimecast-MFC-AGG-ID: AR6twZNIMkixfzurSRktig_1750437661 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437661; x=1751042461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aN7xXBZj4Ftx1dfcGboeMP703/cTHxafXoXtiLZOCMM=; b=cpeLWP6B7croz1avIEySROKNwqX93zH2889BQJlMUIhyygbnpEibtrGxeGIvPtSbfU 1cMY4pAfO/I4fB/WsUXDQgD5x6vtKAwfVXG9tYXNbItXFGj+z3isDPiLoqNvbSH2VN/9 wwH4HqWr2+R8FQxDeKR1hYxP5b4QEW7CUbCrFqZRDIfTklR5Ctwpc8Bdj7zT3t0nqAk8 3rdW0v/GegTLBmxRLJXzbsLzSMrtRzPQnyrwTkxlXcxeOjoCuGvw/smAYA323KET5Xrk KIT7955VubNoFjaa8fBOKuz0O4l2P4nOva3byAevUQJIz42KVnNeU0rpWoyTpJIxGNoo N/kw== X-Gm-Message-State: AOJu0YwpSSap0R/z/38QXkCiad9BmF6CoGs1BM9SVL1dgNIgHjAUmQxp PHIflWToSw3pXumf57wXvto2S2YWqVu70Q1mLAk6iz3TEU7KsBmOrRxeZiGwE6FEQZNZHxcW6Gf VPAMAtd3szKKg7sJafB4xGSje4ozoNWS/kS10w/fPIIJNYTyWpXaKzefOB9wZpBSnQc1TD9sxAg cxQ0N8AgFNGVephrB7x3B+QJZJ4oXPaAICc4yGAo/v X-Gm-Gg: ASbGncsiQHn+nmtNBk1k+271txyqo8Wj2lRww6f2p3+Lu+SRPtY436aWdpH5gcrge4s Puiw4llwFOJqv+2kWxNn0bxW3FbEeWAgZmrVBlxXx52oGTLJ0YJTmxWCK+HAvuIfu4HU8sOL77h 7x5XWJbgPhg1JQzIx6/Z9SIYa4R6zx0uiZDuzwm4SYBb+oIVRjCHqq29IZVnWsNH5EK1OHAzslR mBQrToMZ/L67k11B7JnA0oVaCn7fAD6i9yv4yQqFEqt0zeRmkqfdWE1GSFE44h5mH5KnbnGwoaV 9vsf+AMjc/H5gsqy1fOi7/2VTg== X-Received: by 2002:a05:6402:34cc:b0:607:35d8:4cf8 with SMTP id 4fb4d7f45d1cf-60a1ccbc846mr3361886a12.11.1750437660551; Fri, 20 Jun 2025 09:41:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3JFuqE+dcd5fdcKUjRpgdDxKTjtijkxVvb+SPO11XtYAxXv/TItUZ6edJWO0hoyAyQlOheA== X-Received: by 2002:a05:6402:34cc:b0:607:35d8:4cf8 with SMTP id 4fb4d7f45d1cf-60a1ccbc846mr3361853a12.11.1750437659917; Fri, 20 Jun 2025 09:40:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Peter Maydell Subject: [PULL 02/24] target/i386: fix TB exit logic in gen_movl_seg() when writing to SS Date: Fri, 20 Jun 2025 18:40:30 +0200 Message-ID: <20250620164053.579416-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437806263116600 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland Before commit e54ef98c8a ("target/i386: do not trigger IRQ shadow for LSS")= , any write to SS in gen_movl_seg() would cause a TB exit. The changes introduced= by this commit were intended to restrict the DISAS_EOB_INHIBIT_IRQ exit to the= case where inhibit_irq is true, but missed that a DISAS_EOB_NEXT exit can still = be required when writing to SS and inhibit_irq is false. Comparing the PE(s) && !VM86(s) section with the logic in x86_update_hflags= (), we can see that the DISAS_EOB_NEXT exit is still required for the !CODE32 case= when writing to SS in gen_movl_seg() because any change to the SS flags can affe= ct hflags. Similarly we can see that the existing CODE32 case is still correct= since a change to any of DS, ES and SS can affect hflags. Finally for the gen_op_movl_seg_real() case an explicit TB exit is not needed because the s= egment register selector does not affect hflags. Update the logic in gen_movl_seg() so that a write to SS with inhibit_irq s= et to false where PE(s) && !VM86(s) will generate a DISAS_EOB_NEXT exit along wit= h the inline comment. This has the effect of allowing Win98SE to boot in QEMU once again. Signed-off-by: Mark Cave-Ayland Fixes: e54ef98c8a ("target/i386: do not trigger IRQ shadow for LSS") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2987 Link: https://lore.kernel.org/r/20250611130315.383151-1-mark.cave-ayland@il= ande.co.uk Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 0fcddc2ec08..0cb87d02012 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2033,8 +2033,11 @@ static void gen_movl_seg(DisasContext *s, X86Seg seg= _reg, TCGv src, bool inhibit tcg_gen_trunc_tl_i32(sel, src); gen_helper_load_seg(tcg_env, tcg_constant_i32(seg_reg), sel); =20 - /* For move to DS/ES/SS, the addseg or ss32 flags may change. */ - if (CODE32(s) && seg_reg < R_FS) { + /* + * For moves to SS, the SS32 flag may change. For CODE32 only, cha= nges + * to SS, DS and ES may change the ADDSEG flags. + */ + if (seg_reg =3D=3D R_SS || (CODE32(s) && seg_reg < R_FS)) { s->base.is_jmp =3D DISAS_EOB_NEXT; } } else { --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437733; cv=none; d=zohomail.com; s=zohoarc; b=ihVMeXL71UmarRPsYUpKx8UIkapUDSD9UL1nvcda2krrs3X1IFJ14SBixpRjb36vgL6nm7w/zyVupcGBd7k8ZMBnL+fruLDIZyErAH2d/tZIVU/rvb13GfUwR9GrzFbJ1449U12qU0ADsZ8h8trJODQCnchna695FvB4l7JXVDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437733; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a6qBhhYU0EtvM14oRBz0nwskdUiQCwK4GxAn5RYA6Xc=; b=XRMTLbGkMuDeeL3jHe2n4s6U2bg1fQnkv11PxFJavoIYBOlWy7pO6mNkfqTeZcj+yHOQgU4nsmkSiFiXiSqXAKnfWKh6sMvDlW8izSHvmf9I69cx0wayv5B2a/Hb9vqjmkJlRzQsFkwe0fAxuCOVTCKkRVBKyjdBgbSc77D3lIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437733715730.9987005977243; Fri, 20 Jun 2025 09:42:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSene-0006TZ-OA; Fri, 20 Jun 2025 12:41:10 -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 1uSenc-0006TA-8g for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSena-0000Dy-Oy for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:08 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-oeak_Qi_M6awbnF6VFp45g-1; Fri, 20 Jun 2025 12:41:04 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-6077833ae13so1591880a12.1 for ; Fri, 20 Jun 2025 09:41:04 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a18d0186fsm1626737a12.72.2025.06.20.09.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a6qBhhYU0EtvM14oRBz0nwskdUiQCwK4GxAn5RYA6Xc=; b=eRzEHIif0aHESKd9b+ubv2ufFG8hY+bf1OjZ3rmSt4OtfuyhLT6e8EB3FOZElt9Nq+6cN2 H73i8LHxL8F31Ijiv2OYPn6Gc12ksJsrTHUAgnECapSJqdKkiwRayKJGZyTCQYjzY3MdUw oHVS3Su2CvdqUCzX3sftFDc888/6sac= X-MC-Unique: oeak_Qi_M6awbnF6VFp45g-1 X-Mimecast-MFC-AGG-ID: oeak_Qi_M6awbnF6VFp45g_1750437663 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437662; x=1751042462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a6qBhhYU0EtvM14oRBz0nwskdUiQCwK4GxAn5RYA6Xc=; b=Alv+gTg2cMxP4KHEe1CPNZT29YLYsCUds2pvKCejRLolFSsK4g0szxm4tqkkBEnbgA 7sM9i9hHIMkLZV/aT+B+OGueRRywua/ru2u8f0+NHabQXaHX+Dl7Le/ma/oXxe2oXBpZ 4p8gOV4WD0fyTBHaDBJkq8yuSdsIBwJXmDDEGkXZxKvHpAVrmdwWORkkhfEKGreZseR7 QX0zOUh6QNNlLiIni16Uu1VF9xqnL8BlTtRUttRKfsgKQLwSwq4BlGHzPlHshUaG8iKx PrDcdH6WkSl3t2hoghEgKPGiEz980FPFJ/aMasiKmlIAxf+JQjRuEB1NUkO5HY52ElCl LZ/A== X-Gm-Message-State: AOJu0YwYOsqtQp0oMhuf11VZeMJYRu4HEvAyXT0KJY5dS2rLcgM6jF7Z Na2T31Q23tOXdzpEFLVircK9s61AH1Ilk4fk7AqbV0iRvsCjv6SKawhUyCAKInpwz6FOIeO2AEz tMVTmhGAbMVrooW1kJNRY+sA3ey2m55s8sh4W236lNU5q/eT4jtHa16SfSw0WTXM4pFCNi3WAxj +5qn+KzdHJzWcT484mAKKroLvihNJwSTrv0YAuVNzH X-Gm-Gg: ASbGnctffjGsf3gX4zVPkB7GvEX7/IFreTe8jBH7YKo/QV1SNiWk3xRx/jNdpduA61W AwviEFRaBse6e0KemRkQBg+gnxX/rvmFWNpiikC0Ruh26hHLwU0GxmiAkazTKs3GK8clGm/Flwp 1eQGBhLPpp54wCTwF/qgzWhrIl0vnH4gs0hWlpIqqjUSVwQtRqkEW6r+5v5c6kO56nHCHuD/wct RautvTT9hgXkTy4ey1REnRyie3HFrqcuBWopZMaoZJbR9QZajXLxiACM7fEtWuR3Czg7rFRNtXT rzkqaz2yvLgXDplyiwzgX4tQDg== X-Received: by 2002:a05:6402:274a:b0:601:8481:3268 with SMTP id 4fb4d7f45d1cf-60a1d183e66mr3202880a12.25.1750437662388; Fri, 20 Jun 2025 09:41:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpaNZzFQOOIniltBH0eOpP8fFnwWWWY+FRCIdjsyzWy3dlm1XcaFI2dWTaaf0+xJrzepMfUQ== X-Received: by 2002:a05:6402:274a:b0:601:8481:3268 with SMTP id 4fb4d7f45d1cf-60a1d183e66mr3202863a12.25.1750437661989; Fri, 20 Jun 2025 09:41:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow Subject: [PULL 03/24] hw: Fix type constant for DTB files Date: Fri, 20 Jun 2025 18:40:31 +0200 Message-ID: <20250620164053.579416-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437735450116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Commit fcb1ad456c58 ("system/datadir: Add new type constant for DTB files") introduced a new type constant for DTB files and converted the boards with bundled device trees to use it. Convert the other boards for consistency. Fixes: fcb1ad456c58 ("system/datadir: Add new type constant for DTB files") Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20250610204131.2862-2-shentey@gmail.com Signed-off-by: Paolo Bonzini --- hw/arm/boot.c | 2 +- hw/ppc/e500.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 79afb51b8a5..64040504a1e 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -527,7 +527,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_inf= o *binfo, =20 if (binfo->dtb_filename) { char *filename; - filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filena= me); + filename =3D qemu_find_file(QEMU_FILE_TYPE_DTB, binfo->dtb_filenam= e); if (!filename) { fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_file= name); goto fail; diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 6899802bedd..723c97fad2e 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -408,7 +408,7 @@ static int ppce500_load_device_tree(PPCE500MachineState= *pms, =20 if (dtb_file) { char *filename; - filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_file); + filename =3D qemu_find_file(QEMU_FILE_TYPE_DTB, dtb_file); if (!filename) { goto out; } --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437733; cv=none; d=zohomail.com; s=zohoarc; b=cQ7NDivgqtQJwZe0tELTKWq3Hcri4OHG7GtL/jCSGxq5qv7BLzaPXsNv4L992awuITQWhNixOQOQ7nlhsu51hXgtX+4hjYhn3SnZrgcHL/z6whzKIFYcptokavsj4PGj2RxeTrNrnbegg6mRYGN1OMxLHzakju/rDFA6kBdPRs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437733; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DUIvp1cz9YnyvC95Tjas0YvfK3IAXVWPKg+/hWgdCnQ=; b=J7IJ7WdAOd0VAOUcxk8M/4WbmBSF9bjAC0smPIUTkTl1R92GdtUERR+vF3BVKvY2wfv+7RZag9NCY0/VhAOo9wpkO8i5nj5LqODKAYFz7bBOJ0yPrO/A0c68G9ONDCjSEGIajkiMcyxcFlO7Nk4vm7cP4gzWgel82JNXhGzLXAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437733835132.51579340055912; Fri, 20 Jun 2025 09:42:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSenh-0006Uf-UQ; Fri, 20 Jun 2025 12:41:13 -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 1uSeng-0006UT-Ig for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSene-0000EU-CN for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:12 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-m0MttppVM1OQGkio8HV88A-1; Fri, 20 Jun 2025 12:41:07 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-ad8a0eef39bso116584866b.3 for ; Fri, 20 Jun 2025 09:41:07 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053e7f53fsm186007866b.28.2025.06.20.09.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DUIvp1cz9YnyvC95Tjas0YvfK3IAXVWPKg+/hWgdCnQ=; b=Inc0w13PhfiQpw8DytpvqqzYcWWxNLcczqph/zkHP/Qsgmn1JKqLuBNEo3IBzq4kFzdgbT kYrskESDVsbQIcyq/p7RpSYujZ1G6a2/jCLDB3mZ0MVeAK/FuX2PFZg2NcRKjMNp42JYSx oDGRRu8qy/d3S93COqFTdkB+TK6sFq4= X-MC-Unique: m0MttppVM1OQGkio8HV88A-1 X-Mimecast-MFC-AGG-ID: m0MttppVM1OQGkio8HV88A_1750437666 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437665; x=1751042465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DUIvp1cz9YnyvC95Tjas0YvfK3IAXVWPKg+/hWgdCnQ=; b=G0wPUhauFax97mLMSm7tBdBki2C7qjbawajeSHBQRpsfBYs6/KATdjUY9WiHQnwYdj 7o47hHAC+acmkPPApGatZ56NXo7UUh/Z7eIvn9zK5mZipVYlyuHMGADktxlSpt1Q4KXe ZkH/4B4Eqxmgv16f33HPH97ueSxX02tZOHOaCN2OTx4xqaaOVnJ/uqotVf1TLL3L7icg 1mKteEXRvNhBMmAFytemwl6yvU8zaLCSrBvGjgGzrq4NAoPhbWI/zSmiDltrESJuz74H 1YRk+N79lu9KxZiHAMmazxJJi6oqhHy+Mbe780lgEvpfJCy2mgzp6r/PX+gQ1EUJAAWB X/+g== X-Gm-Message-State: AOJu0YzOxnQFwkcm+qcr/5zRXQA+vU4aGBplg5AzY7o+im9tOKqKUO7b KVF4f7chFQQh8OqojUPJKwQIHeYqBCJcw1nEfh+R8Vx3c9c5SmZzTKKC/XO3Op2OJYK7Gr+dhKv MxkoNdeOZIwdTwhBPDaDD31I09TOGFwAROt8++Y5ujm4Bqjep24B+uXFEhQjXaPcfMEKNDXfdz7 1DPyXNtMG1NS0y5q+oZRyyyHJXiN8V244f5G1UMoSQ X-Gm-Gg: ASbGncvccUYYEjK2FTYkB4bZ2wBxelfrMpeqmZXnpBa5EpAmMEI8kLlk+PalTeTjmfI xmwpIJts6+kqLVj0vclPeZNk3kSaZcBcTuF8vtcp+CABkBtsQtwVcL+TnJ19WLg7XHLuolslU/8 u2m+Ov3zoCwPAj9y7L4uyqnf6m/NTHVYCdq737Dob2o3MXYX9255LLFIQKJ5DMqRBtU4kRSXV09 25dL7gw/k9XSVWshuHPP1j5nygWyNMT/raCXANxzPDbBGgXtnIqhnsE07gxCIELsMWYLlOHqv90 TOa14HlEnFsk2EKRc+fLXkUSuw== X-Received: by 2002:a17:907:3f96:b0:ae0:66d2:8953 with SMTP id a640c23a62f3a-ae066d28f02mr108144166b.45.1750437665213; Fri, 20 Jun 2025 09:41:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGL3bZFmb97tLVSwdIlp8JlmRW6LpCBRtS3g49u09GT9AY+SZgEIkx0yKcWv1AYOJuy3020Sg== X-Received: by 2002:a17:907:3f96:b0:ae0:66d2:8953 with SMTP id a640c23a62f3a-ae066d28f02mr108142066b.45.1750437664767; Fri, 20 Jun 2025 09:41:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow Subject: [PULL 04/24] pc-bios/dtb/meson: Prefer target name to be outfile, not infile Date: Fri, 20 Jun 2025 18:40:32 +0200 Message-ID: <20250620164053.579416-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437735414116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Makes this custom_target() usage consistent with other ones in QEMU. Fixes: 6e0dc9d2a88a ("meson: compile bundled device trees") Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20250610204131.2862-3-shentey@gmail.com Signed-off-by: Paolo Bonzini --- pc-bios/dtb/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc-bios/dtb/meson.build b/pc-bios/dtb/meson.build index 7a71835bca7..993032949fe 100644 --- a/pc-bios/dtb/meson.build +++ b/pc-bios/dtb/meson.build @@ -9,7 +9,7 @@ dtc =3D find_program('dtc', required: false) if dtc.found() foreach out : dtbs f =3D fs.replace_suffix(out, '.dts') - custom_target(f, + custom_target(out, build_by_default: have_system, input: files(f), output: out, --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437733; cv=none; d=zohomail.com; s=zohoarc; b=KrS1So5bcx1tLGPf6QBq3q7vdubGg+4tV1bezzgoFj7tk19+79oLb8SWZidyqizF0IPJAmrEZ4UgtJFFoWOiimNrxrErScBcmTfIsr5OfxZY7o0vTX5xJoG6Aabwi5KfLaFtzBllRqydQuVOB/XLL35uEyzbj+DaI52vg+FY+bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437733; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WkypQBs3Sa9da/mafe2M70UFin4AWq9me2xp5g/DFmw=; b=L7Q1MNZKprfkajq2d7raDdtqcXyXjbzpmTvriUxz8IvBziV+kFWmSQzUVtk/6EtN/ku3TiMojIMznyaZ5KkdF4WoSJLfafVp1krouyN8Y4S34s0pgY8yVhox0kRFAxO8eL8Lxk/oZaikImIq1LlnnQI8ghRmPJ85A1BdHccAWpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437733765824.8048746785071; Fri, 20 Jun 2025 09:42:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeno-0006W7-DJ; Fri, 20 Jun 2025 12:41:20 -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 1uSenm-0006Vt-LA for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenk-0000FD-P8 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:18 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-I2aV4cJlOr63wDTsA550tw-1; Fri, 20 Jun 2025 12:41:09 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-ade6db50bb4so147884166b.2 for ; Fri, 20 Jun 2025 09:41:09 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae054080dbdsm185493666b.76.2025.06.20.09.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WkypQBs3Sa9da/mafe2M70UFin4AWq9me2xp5g/DFmw=; b=Ew4sqcuXLBjxn3x2uBLk1YKMeHBFkLCA74dzzcxHVuLTnA5XaQCo2r3PNHWqSy7s5K+7c5 u1dNwSM4YbMMgPioAoanMRIXpnFSz2oxR4Po+M+fDVb9YndcU1bvGdB2fhsHftNgjNI3C5 +RAWcU3/xyg2QJzo7V2qOvaUJil1xik= X-MC-Unique: I2aV4cJlOr63wDTsA550tw-1 X-Mimecast-MFC-AGG-ID: I2aV4cJlOr63wDTsA550tw_1750437669 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437668; x=1751042468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WkypQBs3Sa9da/mafe2M70UFin4AWq9me2xp5g/DFmw=; b=U2WT0hf+8py1TYgp6dYD6RiHM5PMT13PsuUNSr6E6cGpmuObHAEgZDy/43paACMyD/ vMREc6koAXiTxhe+/uglrBQsXxBTLepkOTwqWNXlLZWUs2zTFLAQQ4D5yFZvZi+BcDtL BkH020I1kmL4w8XEGwrDHrp398bdStfv/PT/MeJpl6y8jTEV335prg9kwV5uDQgnsgCE 3hFH/mDKTnDyELLSlb/BSeQ/aens5ifvafHDI3nnUV1FpoEpMhI9l8YP7G+4p7M+UNlM 1Ub0j4Y1WGaAdZ+ESlKJbVfPYaR6gSR7IErK2Kw06rkU/aryPzXBf1l9UhoZdgwDM/Ub +vtw== X-Gm-Message-State: AOJu0YyqX9YknV6ghu0xCdJu7eiRA0DZB61Jq4ib0i7eNQDzO1ARbUpI eVuMKwDM4no1cQBQlBWIC0n/2wOPwvaE/TjbpfXaGkFZufRNFPvq755eOMgyl56Oy9kmTXjXK42 zP4gGmujlNwAm9k5gm9W8PlPj4gLW1dhpLMlQyG5Q1TUb6Tr/MkqvTzeAwF2W+zW3QgZodt+ux/ qyl44XevBuIUzvRpCWtaDvzV8ZZUbOUCRaccK7x/uX X-Gm-Gg: ASbGnctUkl7V1NIbmmEkRxxq7pvtvjxQAs4ivLgUhL5p/UN/m+sN8Aszr2VxnmEwRJY MJVr9Q6aSO5CxfFn1BWKkLETysFosNkeMXNyeX7pz9OdKDDGa/iZh1Yhdgb4SM7ODiV8lrQo4X7 Od2gk7NFURZEKUa0pWLHEfAgkwTIgaQLYdyvkcZQ//gHMO/oajgk9k9OmYXxnn1jPhnoGRb0Fv3 6TTA9gipemBg2VgiVYac0On3eDZqKACMmyF9YBwl98GnnlL9LQM6utUBJUurnxsEzHpjUiVvUt9 PivfhTPfeNFjCJi1EYCg2cE2/w== X-Received: by 2002:a17:907:7e95:b0:ade:4121:8d3d with SMTP id a640c23a62f3a-ae0579d0ccbmr317732966b.12.1750437668194; Fri, 20 Jun 2025 09:41:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyVuD0q70sY+MQRuj5/PBIb2e1d+8S2NhbMN1B3vLeINSEAscFnZ3dddj9YqsZBXk3zjnQPw== X-Received: by 2002:a17:907:7e95:b0:ade:4121:8d3d with SMTP id a640c23a62f3a-ae0579d0ccbmr317729666b.12.1750437667616; Fri, 20 Jun 2025 09:41:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 05/24] rust: qemu_api: introduce MaybeUninit field projection Date: Fri, 20 Jun 2025 18:40:33 +0200 Message-ID: <20250620164053.579416-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437735534116600 Content-Type: text/plain; charset="utf-8" Add a macro that makes it possible to convert a MaybeUninit<> into another MaybeUninit<> for a single field within it. Furthermore, it is possible to use the resulting MaybeUninitField<> in APIs that take the parent object, such as memory_region_init_io(). This allows removing some of the undefined behavior from instance_init() functions, though this may not be the definitive implementation. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/uninit.rs | 85 +++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 rust/qemu-api/src/uninit.rs diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index cac8595a148..33653b4a28e 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -28,6 +28,7 @@ _qemu_api_rs =3D static_library( 'src/qom.rs', 'src/sysbus.rs', 'src/timer.rs', + 'src/uninit.rs', 'src/vmstate.rs', 'src/zeroable.rs', ], diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 93902fc94bc..c78198f0f41 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -27,6 +27,7 @@ pub mod qom; pub mod sysbus; pub mod timer; +pub mod uninit; pub mod vmstate; pub mod zeroable; =20 diff --git a/rust/qemu-api/src/uninit.rs b/rust/qemu-api/src/uninit.rs new file mode 100644 index 00000000000..04123b4ae99 --- /dev/null +++ b/rust/qemu-api/src/uninit.rs @@ -0,0 +1,85 @@ +//! Access fields of a [`MaybeUninit`] + +use std::{ + mem::MaybeUninit, + ops::{Deref, DerefMut}, +}; + +pub struct MaybeUninitField<'a, T, U> { + parent: &'a mut MaybeUninit, + child: *mut U, +} + +impl<'a, T, U> MaybeUninitField<'a, T, U> { + #[doc(hidden)] + pub fn new(parent: &'a mut MaybeUninit, child: *mut U) -> Self { + MaybeUninitField { parent, child } + } + + /// Return a constant pointer to the containing object of the field. + /// + /// Because the `MaybeUninitField` remembers the containing object, + /// it is possible to use it in foreign APIs that initialize the + /// child. + pub fn parent(f: &Self) -> *const T { + f.parent.as_ptr() + } + + /// Return a mutable pointer to the containing object. + /// + /// Because the `MaybeUninitField` remembers the containing object, + /// it is possible to use it in foreign APIs that initialize the + /// child. + pub fn parent_mut(f: &mut Self) -> *mut T { + f.parent.as_mut_ptr() + } +} + +impl<'a, T, U> Deref for MaybeUninitField<'a, T, U> { + type Target =3D MaybeUninit; + + fn deref(&self) -> &MaybeUninit { + // SAFETY: self.child was obtained by dereferencing a valid mutable + // reference; the content of the memory may be invalid or uninitia= lized + // but MaybeUninit<_> makes no assumption on it + unsafe { &*(self.child.cast()) } + } +} + +impl<'a, T, U> DerefMut for MaybeUninitField<'a, T, U> { + fn deref_mut(&mut self) -> &mut MaybeUninit { + // SAFETY: self.child was obtained by dereferencing a valid mutable + // reference; the content of the memory may be invalid or uninitia= lized + // but MaybeUninit<_> makes no assumption on it + unsafe { &mut *(self.child.cast()) } + } +} + +/// ``` +/// #[derive(Debug)] +/// struct S { +/// x: u32, +/// y: u32, +/// } +/// +/// # use std::mem::MaybeUninit; +/// # use qemu_api::{assert_match, uninit_field_mut}; +/// +/// let mut s: MaybeUninit =3D MaybeUninit::zeroed(); +/// uninit_field_mut!(s, x).write(5); +/// let s =3D unsafe { s.assume_init() }; +/// assert_match!(s, S { x: 5, y: 0 }); +/// ``` +#[macro_export] +macro_rules! uninit_field_mut { + ($container:expr, $($field:tt)+) =3D> {{ + let container__: &mut ::std::mem::MaybeUninit<_> =3D &mut $contain= er; + let container_ptr__ =3D container__.as_mut_ptr(); + + // SAFETY: the container is not used directly, only through a Mayb= eUninit<>, + // so the safety is delegated to the caller and to final invocatio= n of + // assume_init() + let target__ =3D unsafe { std::ptr::addr_of_mut!((*container_ptr__= ).$($field)+) }; + $crate::uninit::MaybeUninitField::new(container__, target__) + }}; +} --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437764; cv=none; d=zohomail.com; s=zohoarc; b=VzccJPjAYgJ0Vh9p0qaH3lnnyoVdHFGwLWf/PQK8d0YdZ2jUcT8ZUsyzTpghWYSxaWD1cbR96i/0MYnWn5IfblKbiHB+qVaEij5H6N1CbZnKBR13kf7KavKmFFHgW/cnwFuHzrBrYbAYoQPvg/M+6ig25DCZu4FtfsovjGpnfO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437764; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KETZnc4aDehl43qftNGze3IPzLrQSPsMMuMzCI6EM3Q=; b=Qsd4jtITLc4L/jySNGjd0ijYNSD8fayTXAXmwOeIAx4x1gzI8aFno4GgEZ9bCCpa5s7dF6m7AanH4YT/uglVjZe6nqi3IFwLaWo+dd2BalfacS4Rm7983M46oPLSRs/mW32aknYbvkzmMTrZzi2A59l75yYYVGrjVeoRgb6zXk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437764471535.8285369814047; Fri, 20 Jun 2025 09:42:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSenm-0006Vh-FS; Fri, 20 Jun 2025 12:41:18 -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 1uSenk-0006VI-U3 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenj-0000F4-D2 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:16 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-ZR6bHt9fOeKEHmMhb3UDHg-1; Fri, 20 Jun 2025 12:41:13 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-adb5f5f43dfso163925666b.3 for ; Fri, 20 Jun 2025 09:41:13 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae0541b74b6sm185278566b.139.2025.06.20.09.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KETZnc4aDehl43qftNGze3IPzLrQSPsMMuMzCI6EM3Q=; b=fGPx+ZHt5ywpOx6O7q6tt4/QE4FDzJh+MU5wu4n7i7DQU2f1l6pvpPZgJXD2K04mrfpBSm K5VNe12dlDZeesiqcnjsYI8it/FeF0mMp5UCgwHGaPa8CiTFOyFEABT+Vbzp7g0ZaGi2Dd S8yJoyxfxwRBVvvbKrgc3NsTmo9d2iQ= X-MC-Unique: ZR6bHt9fOeKEHmMhb3UDHg-1 X-Mimecast-MFC-AGG-ID: ZR6bHt9fOeKEHmMhb3UDHg_1750437672 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437671; x=1751042471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KETZnc4aDehl43qftNGze3IPzLrQSPsMMuMzCI6EM3Q=; b=oSKkQEoeUy3dNJk8nM3oSvxLlCnwXi4YBbiPnpGmGlQu3tUwkJAuczTbA08JaWuDno httvdTEfR7Th6fUWZ27UBNiKZvUJy61ERTJzSGLkmH76A8KqhTEujVJDLft/NyszN0nw +jXtCq6r3zSdr7bWkXIQBiZx+L4Tg5rnSGcUri/2mZ5PIwTVeWEJlVaVyFI22peLWa6W zhejOdsg481zL4DXPxIscUleh9LOjqQirH+GkP4REjRIl6Iv+8Wr1DT7Fmzlielbovmm pgePE1Mes40xwhb89o4ap2whR8x9UcHze71GPyHSd/kkqqeIQWN2/5GQdBxmPUPCah1I ztRQ== X-Gm-Message-State: AOJu0YydaFKfqA1OXa9+rULa4LoTtBsIEUwaulIfTFY/wquFurKEyvt/ BaZwzWN8y4Mfl7e906iyW0lNsl4QIVmp+ljx6NXKUEjLjJv3KgHZmeLiLpvxVJ517ZPxJv61kY7 JGHzoMs5ttvZBQzinbE55j5aCKQaRiOB0fmjc/aDBcdmbIIc3jxUgaqs6+6T0kmAeyLUm+sQlU7 kVhqXUafMUH0m4RM0tHgnAh0IoEyh/C1xgObX0jCor X-Gm-Gg: ASbGncvCb28izvgmVr1S0o0kkyVYqe9CREYuR682BWK8Sp68Gd2EuIPKAN7P1JTMWD1 5sud9CujWD8WRW3dVK65hK4WQjMklM/bqhjRSVWiPWbFQc0E6i6o/A/mKM/+5/4iUEu0Mp/Tv82 Tr8iY5S5Sha+bcPkNV6PfZem0qWQegbXuLly/6kkVw1LwDeKtrMuzluxkwVpGD+E7v/Ee5IH3zs JRnsSwoJlDhtN+nkUs657hKZi/+or4otYpPoIZebLFHuMs/06re2yM6nDX9iezhr34KblJi5rZL fH0WztILXSjFd6iyaChdrmqALQ== X-Received: by 2002:a17:906:c154:b0:ad8:a935:b8ff with SMTP id a640c23a62f3a-ae057ef75famr395038466b.31.1750437671038; Fri, 20 Jun 2025 09:41:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKIXo5bvf5DFxav6ONdMjZu7+ciCVgv64jhuf5sBoov1UxO9ykrVnJL9NVvOVIBV16bPAvZA== X-Received: by 2002:a17:906:c154:b0:ad8:a935:b8ff with SMTP id a640c23a62f3a-ae057ef75famr395035366b.31.1750437670525; Fri, 20 Jun 2025 09:41:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 06/24] rust: hpet: fully initialize object during instance_init Date: Fri, 20 Jun 2025 18:40:34 +0200 Message-ID: <20250620164053.579416-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437765647116600 Content-Type: text/plain; charset="utf-8" The array of BqlRefCell is not initialized yet at the end of instance_init. In particular, the "state" field is NonNull and therefore it is invalid to have it as zero bytes. Note that MaybeUninit is necessary because assigning to self.timers[index] would trigger Drop of the old value. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/timer/hpet/src/device.rs | 42 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/devi= ce.rs index 735b2fbef79..340ca1d355d 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -4,6 +4,7 @@ =20 use std::{ ffi::{c_int, c_void, CStr}, + mem::MaybeUninit, pin::Pin, ptr::{addr_of_mut, null_mut, NonNull}, slice::from_ref, @@ -25,6 +26,7 @@ qom_isa, sysbus::{SysBusDevice, SysBusDeviceImpl}, timer::{Timer, CLOCK_VIRTUAL, NANOSECONDS_PER_SECOND}, + uninit_field_mut, vmstate::VMStateDescription, vmstate_fields, vmstate_of, vmstate_struct, vmstate_subsections, vmsta= te_validate, zeroable::Zeroable, @@ -212,13 +214,13 @@ pub struct HPETTimer { } =20 impl HPETTimer { - fn init(&mut self, index: u8, state: &HPETState) { - *self =3D HPETTimer { + fn new(index: u8, state: *const HPETState) -> HPETTimer { + HPETTimer { index, // SAFETY: the HPETTimer will only be used after the timer // is initialized below. qemu_timer: unsafe { Timer::new() }, - state: NonNull::new((state as *const HPETState).cast_mut()).un= wrap(), + state: NonNull::new(state.cast_mut()).unwrap(), config: 0, cmp: 0, fsb: 0, @@ -226,19 +228,15 @@ fn init(&mut self, index: u8, state: &HPETState) { period: 0, wrap_flag: 0, last: 0, - }; + } + } =20 + fn init_timer_with_cell(cell: &BqlRefCell) { + let mut timer =3D cell.borrow_mut(); // SAFETY: HPETTimer is only used as part of HPETState, which is // always pinned. - let qemu_timer =3D unsafe { Pin::new_unchecked(&mut self.qemu_time= r) }; - qemu_timer.init_full( - None, - CLOCK_VIRTUAL, - Timer::NS, - 0, - timer_handler, - &state.timers[self.index as usize], - ) + let qemu_timer =3D unsafe { Pin::new_unchecked(&mut timer.qemu_tim= er) }; + qemu_timer.init_full(None, CLOCK_VIRTUAL, Timer::NS, 0, timer_hand= ler, cell); } =20 fn get_state(&self) -> &HPETState { @@ -607,9 +605,18 @@ fn handle_legacy_irq(&self, irq: u32, level: u32) { } } =20 - fn init_timer(&self) { - for (index, timer) in self.timers.iter().enumerate() { - timer.borrow_mut().init(index.try_into().unwrap(), self); + fn init_timers(this: &mut MaybeUninit) { + let state =3D this.as_ptr(); + for index in 0..HPET_MAX_TIMERS { + let mut timer =3D uninit_field_mut!(*this, timers[index]); + + // Initialize in two steps, to avoid calling Timer::init_full = on a + // temporary that can be moved. + let timer =3D timer.write(BqlRefCell::new(HPETTimer::new( + index.try_into().unwrap(), + state, + ))); + HPETTimer::init_timer_with_cell(timer); } } =20 @@ -710,6 +717,8 @@ unsafe fn init(&mut self) { "hpet", HPET_REG_SPACE_LEN, ); + + Self::init_timers(unsafe { &mut *((self as *mut Self).cast::>()) }); } =20 fn post_init(&self) { @@ -731,7 +740,6 @@ fn realize(&self) -> qemu_api::Result<()> { =20 self.hpet_id.set(HPETFwConfig::assign_hpet_id()?); =20 - self.init_timer(); // 64-bit General Capabilities and ID Register; LegacyReplacementR= oute. self.capability.set( HPET_CAP_REV_ID_VALUE << HPET_CAP_REV_ID_SHIFT | --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437861; cv=none; d=zohomail.com; s=zohoarc; b=GXbLBkhwIjYBRBqHNjGwGhOhJQUPf6FUKtlYkq9qqRMG8VJvWg8d3rThq+jwhNDblanABpmODJfJFzL7oGlmMCkdY0pacu1B4bPE3aLvrNsf9GHc4yQF/DvmqrkiJhrYAva+frTt7l4XikhISUiqkSeJnqVyfggs/BXqblNt2sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437861; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZbRxtT0IMJemouiEORMDGr9tGSaeLkY1c3ABjRf1eR8=; b=kxKFifDw8GfWijNsKlaEz12umFuEs/37PCpkqFzHqht5eyQ46kmqagsg2AuM5ReeTGLOKumaT6U51aWc9YqucFiBF8tBmy3CcDYi25U/gjXsZ1BQqKZVZXU3te0PEtlqoj6LrnQW6nKkQdKsCSS7o82oCWx1nLbPfUGL0coPaGA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437861811481.9997154027516; Fri, 20 Jun 2025 09:44:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeo5-0006Zq-Bq; Fri, 20 Jun 2025 12:41:37 -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 1uSeo2-0006Yu-5W for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenz-0000Gq-UU for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:33 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-604-v8-5ykeGP86BXIDR9iRdcA-1; Fri, 20 Jun 2025 12:41:16 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-adb5f5f43dfso163930866b.3 for ; Fri, 20 Jun 2025 09:41:16 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae054209a2dsm190213166b.174.2025.06.20.09.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZbRxtT0IMJemouiEORMDGr9tGSaeLkY1c3ABjRf1eR8=; b=JP8UPdnXVuIB1I2RDw1Oi73mlJQNBDdRAtf4Uul2s7y/tn4Meo5Cy3Gfb0C5iyijkC6zLl RA1d8zsMRRiO3av5ZOO08nwdqKjoPX5tyJVg/9xqLmpNJaVBbM7XjxBgKi9aglraAg2wPC WQ23u4jX0wq03edIWFqR9V3oGak6FzQ= X-MC-Unique: v8-5ykeGP86BXIDR9iRdcA-1 X-Mimecast-MFC-AGG-ID: v8-5ykeGP86BXIDR9iRdcA_1750437675 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437674; x=1751042474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZbRxtT0IMJemouiEORMDGr9tGSaeLkY1c3ABjRf1eR8=; b=o/pl0HHobNo+QbE2JIfeYXiHQJRNcGT0WVJR3d83+bA4pg3zUsiKaPfCFRcHyhN5o1 Njoubpc2uR9Djq1J9dBGUHngRmnTvOAbcL7FdrrDnf8m9QqIHKLKI8Jp9gEqQ3VB9InP zeK3SJKTEQlnwBflp20swDjAz8R5EZZH0qZfY7WcxFq7HxYbk6cmeK1oUVdf/1xcNviW d1acTlOTh5v9C0awFWVTPiig7SxBeblVhcUgdYwlYSZ/avDRUPml508nMmp8MgLRJHx7 653kYccu+c3S0lSz5JYdC98Z8RlFJpxQCOzfX/UbWUtjIt+imi30BRChtUvxqC1WHnwX LByg== X-Gm-Message-State: AOJu0YxvDiVDJsB7YwlnN5xDDu9Xdbl1feOOf3jybf+pkD0c6jiilVAG xroewK14tR+9XSvJj5YnymlySO2NohLGqrdH2vAITBUU6De4YPf5R29a0QFfQji1MgEttJLXjUK m77Ho42qU2wXsnSZnn6yAeMT/lqL2EZSHiOKvuD3sdfuBSkOLRlgcy/aXke+2wriMkVdVwSV9hd XobWFIvFXx1A1PTJx5DnnsRpAHB1oL1n4U1hxiAHyD X-Gm-Gg: ASbGncvySDOnoaYHAePvN3YfJK3n5ywYRItonS82iqFEqRoFTGnxLtIg/MhA4PsYleE +x5k+5vTgIWtLgzUQ/Uy4+WIHYieh8iY46yAY7o70xqMRENxAdiYgl2FygNc6uUa96Hy7LALuYo hYAU7ilpw80kTEeKs0R/wJq6lxollkSaSqIgfs9Y6EZMkCmkRdVP1/wm7nPROuW9UFmIul6/oVV CtENLedXHIPTUc5mF3NfxMzojZrF0shZ3snOGQA1MtwNbdjfFu3exWPize/IqIDWY58ioGdWhFB 1hZ6ZMYGzYCQ+1QlkMmNAq347w== X-Received: by 2002:a17:907:9715:b0:ad8:9b5d:2c38 with SMTP id a640c23a62f3a-ae057d4d2a3mr350810166b.26.1750437674302; Fri, 20 Jun 2025 09:41:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjeaEMwqFfV9E8dSGQzWMqgp1qiygxRbnsjANyqiuxT+7P/gN4UDB8YsHXsV67tXWKOMAZGQ== X-Received: by 2002:a17:907:9715:b0:ad8:9b5d:2c38 with SMTP id a640c23a62f3a-ae057d4d2a3mr350807566b.26.1750437673789; Fri, 20 Jun 2025 09:41:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 07/24] rust: qom: introduce ParentInit Date: Fri, 20 Jun 2025 18:40:35 +0200 Message-ID: <20250620164053.579416-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437862771116600 Content-Type: text/plain; charset="utf-8" This is a smart pointer for MaybeUninit; it can be upcasted to the already-initialized parent classes, or dereferenced to a MaybeUninit for the class that is being initialized. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/qom.rs | 96 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs index 14f98fee60a..ef966e570ca 100644 --- a/rust/qemu-api/src/qom.rs +++ b/rust/qemu-api/src/qom.rs @@ -95,7 +95,7 @@ use std::{ ffi::{c_void, CStr}, fmt, - mem::ManuallyDrop, + mem::{ManuallyDrop, MaybeUninit}, ops::{Deref, DerefMut}, ptr::NonNull, }; @@ -206,6 +206,100 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(= ), fmt::Error> { } } =20 +/// This struct knows that the superclasses of the object have already been +/// initialized. +pub struct ParentInit<'a, T>(&'a mut MaybeUninit); + +impl<'a, T> ParentInit<'a, T> { + #[inline] + pub fn with(obj: &'a mut MaybeUninit, f: impl FnOnce(ParentInit<'a,= T>)) { + let parent_init =3D ParentInit(obj); + f(parent_init) + } +} + +impl ParentInit<'_, T> { + /// Return the receiver as a mutable raw pointer to Object. + /// + /// # Safety + /// + /// Fields beyond `Object` could be uninitialized and it's your + /// responsibility to avoid that they're used when the pointer is + /// dereferenced, either directly or through a cast. + pub fn as_object_mut_ptr(&self) -> *mut bindings::Object { + self.as_object_ptr().cast_mut() + } + + /// Return the receiver as a mutable raw pointer to Object. + /// + /// # Safety + /// + /// Fields beyond `Object` could be uninitialized and it's your + /// responsibility to avoid that they're used when the pointer is + /// dereferenced, either directly or through a cast. + pub fn as_object_ptr(&self) -> *const bindings::Object { + self.0.as_ptr().cast() + } +} + +impl<'a, T: ObjectImpl> ParentInit<'a, T> { + /// Convert from a derived type to one of its parent types, which + /// have already been initialized. + /// + /// # Safety + /// + /// Structurally this is always a safe operation; the [`IsA`] trait + /// provides static verification trait that `Self` dereferences to `U`= or + /// a child of `U`, and only parent types of `T` are allowed. + /// + /// However, while the fields of the resulting reference are initializ= ed, + /// calls might use uninitialized fields of the subclass. It is your + /// responsibility to avoid this. + pub unsafe fn upcast(&self) -> &'a U + where + T::ParentType: IsA, + { + // SAFETY: soundness is declared via IsA, which is an unsafe tr= ait; + // the parent has been initialized before `instance_init `is called + unsafe { &*(self.0.as_ptr().cast::()) } + } + + /// Convert from a derived type to one of its parent types, which + /// have already been initialized. + /// + /// # Safety + /// + /// Structurally this is always a safe operation; the [`IsA`] trait + /// provides static verification trait that `Self` dereferences to `U`= or + /// a child of `U`, and only parent types of `T` are allowed. + /// + /// However, while the fields of the resulting reference are initializ= ed, + /// calls might use uninitialized fields of the subclass. It is your + /// responsibility to avoid this. + pub unsafe fn upcast_mut(&mut self) -> &'a mut U + where + T::ParentType: IsA, + { + // SAFETY: soundness is declared via IsA, which is an unsafe tr= ait; + // the parent has been initialized before `instance_init `is called + unsafe { &mut *(self.0.as_mut_ptr().cast::()) } + } +} + +impl Deref for ParentInit<'_, T> { + type Target =3D MaybeUninit; + + fn deref(&self) -> &Self::Target { + self.0 + } +} + +impl DerefMut for ParentInit<'_, T> { + fn deref_mut(&mut self) -> &mut Self::Target { + self.0 + } +} + unsafe extern "C" fn rust_instance_init(obj: *mut bindings:= :Object) { let mut state =3D NonNull::new(obj).unwrap().cast::(); // SAFETY: obj is an instance of T, since rust_instance_init --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437742; cv=none; d=zohomail.com; s=zohoarc; b=PqmHA1R+2JAvRDmkpOIeMWf8DJEi9nano1E4I2LDh0JDozMENPEkqsAFkEwgg+ypMH+fBHPAjEVjTqL/fXf6y+XiJOJgaXQuGbu1vK88I3n2syyE2vwMTa5iqW344qb1UGw7Rpn1ksoKLHJ+YIorsMYksIkJ/Oj0WvnTyzSpNAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437742; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P0ToVja12+bxntDkM4pyBWaD2U29e/LsVsIKe4q19RE=; b=RCG8jUVimC12wKv2Jrpb+f508iFkovoUY1yWW2R4KYvEzAY4xqwpYWuiQwQpaxuNNYyl+/tAtTWNLFAaEf8jUc50vhDq39XdTjvueyd+vjVMMOhGM/axIjFm+dCv70T3Y/IuLRrHA0Ao0Zpyi++l+3TfL2SfMTiFj4bLbM33ItI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437742246894.5927296966588; Fri, 20 Jun 2025 09:42:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSenv-0006XV-Dd; Fri, 20 Jun 2025 12:41:28 -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 1uSens-0006X0-1u for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenq-0000Fk-8m for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:23 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-317-FcvnPXdGOOGAuNXNCHySiw-1; Fri, 20 Jun 2025 12:41:20 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-ad89a3bcc62so152222066b.0 for ; Fri, 20 Jun 2025 09:41:19 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053edc0e9sm188735466b.54.2025.06.20.09.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P0ToVja12+bxntDkM4pyBWaD2U29e/LsVsIKe4q19RE=; b=TLwcbRKwPLCxW5XzClk8SD2EniBPmlnZN76esUnQ/dQQRvoW/Wi0tQXZEAMZ7mHkd84baH Pkuf0g4y9v/uNg9ZWHBYsTbXFOehD2Ofho5FSTxuXfs065pIi0BFmvEXS3i8Xll14/LIzp XWPiFJB7mHX7Us4/bNlgq5l+Z0/O+6E= X-MC-Unique: FcvnPXdGOOGAuNXNCHySiw-1 X-Mimecast-MFC-AGG-ID: FcvnPXdGOOGAuNXNCHySiw_1750437679 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437678; x=1751042478; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P0ToVja12+bxntDkM4pyBWaD2U29e/LsVsIKe4q19RE=; b=BibAXEYiKdY691R+7ysMNrO7B/onuaZTxHy7TY5HjC5js5KKyEQ/ppBRyBR1siRw2A sGmSrWBFX79M/0pVFpFGFEMgOjCpFuwfoftzSZaD2RJ/MjeGHjRvig7zhNT309FR/UWY VAnqrrXEAZV0y/W5z4G2QpUM6l7VVRQTaoKMPe1zCbVZGZQbBNC9X8CW75V/9Hz01zvo 8kOLZm1lHffWlXLcUNs8tre7CoxneW6Glo1TyGE3pvfELEcDYpfdirY9FICLKnjewco4 DPA7tUZbqizlAYMd1SPqGU1TctjVzsYUiPJN5kxKHXKJEnp46DoWeeY7BkqbA7YqxwYq ulAA== X-Gm-Message-State: AOJu0Yx/907Qaxakyz+P/SVkcHN0iWFAFsiVmbp9QER+46CmhByatHYK IiVamvfCX8XdzymGhEWS2Bcb3OVPptYbmKkzO0F7DYSHMfbRy1BhoynEtpb0hqithCs7c+U+sax Cthm7QOyDFjms9scbJrufp/PGTATwMrG5H+JaD21aw3p5qZc6FxZ9aWGv8PlKcbn4XUYSOdk6sz R2hEBTngTcTINMG9yyiMpvkxvEhTjHlrp/98AWrU1r X-Gm-Gg: ASbGncvSZjyTim+4afLgT3akYaoefs8KxrGQtkiHuLZw0FOdYSBqcHyQoiCVJFPXBDY O2GT649NzVNtv92TgZ0zVI+I+6VRm2dzi4QVUr3lU0t9Wtj04NY2EkqewFXw952Vylxv0Q7H085 gilbBaOnNvquyUal5NtE2eJJZD9BVfDd2mW4PifdENA6WenXsImEZxu5ogXYYSpbQkHEuPbxeeA WiD2rSmg0+jbCa9nTdfswGy1pLVgFGrs8EECrnZBexxaPUQtfU+MjM4ZtNdVqjMsWPJExBs5dlJ EtuWA6+tp+WzTKDv5aSmidyTmA== X-Received: by 2002:a17:907:1b29:b0:ad8:9257:573d with SMTP id a640c23a62f3a-ae057a0826bmr325331966b.24.1750437677760; Fri, 20 Jun 2025 09:41:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHv+cX4lo9hxNHLN1cuQI0Zi/KLvmxBBXi8M9d4HlRrjFgbQzjm+HjNmik3eZjbeofkiwtadA== X-Received: by 2002:a17:907:1b29:b0:ad8:9257:573d with SMTP id a640c23a62f3a-ae057a0826bmr325329366b.24.1750437677218; Fri, 20 Jun 2025 09:41:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 08/24] rust: qom: make ParentInit lifetime-invariant Date: Fri, 20 Jun 2025 18:40:36 +0200 Message-ID: <20250620164053.579416-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437743359116600 Content-Type: text/plain; charset="utf-8" This is the trick that allows the parent-field initializer to be used only for the object that it's meant to be initialized. This way, the owner of a MemoryRegion must be the object that embeds it. More information is in the comments; it's best explained with a simplified example. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/qom.rs | 89 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs index ef966e570ca..04d102591dc 100644 --- a/rust/qemu-api/src/qom.rs +++ b/rust/qemu-api/src/qom.rs @@ -95,6 +95,7 @@ use std::{ ffi::{c_void, CStr}, fmt, + marker::PhantomData, mem::{ManuallyDrop, MaybeUninit}, ops::{Deref, DerefMut}, ptr::NonNull, @@ -208,12 +209,92 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(= ), fmt::Error> { =20 /// This struct knows that the superclasses of the object have already been /// initialized. -pub struct ParentInit<'a, T>(&'a mut MaybeUninit); +/// +/// The declaration of `ParentInit` is.. *"a kind of magic"*. It uses a +/// technique that is found in several crates, the main ones probably being +/// `ghost-cell` (in fact it was introduced by the [`GhostCell` paper](htt= ps://plv.mpi-sws.org/rustbelt/ghostcell/)) +/// and `generativity`. +/// +/// The `PhantomData` makes the `ParentInit` type *invariant* with respect= to +/// the lifetime argument `'init`. This, together with the `for<'...>` in +/// `[ParentInit::with]`, block any attempt of the compiler to be creative= when +/// operating on types of type `ParentInit` and to extend their lifetimes.= In +/// particular, it ensures that the `ParentInit` cannot be made to outlive= the +/// `rust_instance_init()` function that creates it, and therefore that the +/// `&'init T` reference is valid. +/// +/// This implementation of the same concept, without the QOM baggage, can = help +/// understanding the effect: +/// +/// ``` +/// use std::marker::PhantomData; +/// +/// #[derive(PartialEq, Eq)] +/// pub struct Jail<'closure, T: Copy>(&'closure T, PhantomData &'closure ()>); +/// +/// impl<'closure, T: Copy> Jail<'closure, T> { +/// fn get(&self) -> T { +/// *self.0 +/// } +/// +/// #[inline] +/// fn with(v: T, f: impl for<'id> FnOnce(Jail<'id, T>) -> U) -> U { +/// let parent_init =3D Jail(&v, PhantomData); +/// f(parent_init) +/// } +/// } +/// ``` +/// +/// It's impossible to escape the `Jail`; `token1` cannot be moved out of = the +/// closure: +/// +/// ```ignore +/// let x =3D 42; +/// let escape =3D Jail::with(&x, |token1| { +/// println!("{}", token1.get()); +/// // fails to compile... +/// token1 +/// }); +/// // ... so you cannot do this: +/// println!("{}", escape.get()); +/// ``` +/// +/// Likewise, in the QOM case the `ParentInit` cannot be moved out of +/// `instance_init()`. Without this trick it would be possible to stash a +/// `ParentInit` and use it later to access uninitialized memory. +/// +/// Here is another example, showing how separately-created "identities" s= tay +/// isolated: +/// +/// ```ignore +/// impl<'closure, T: Copy> Clone for Jail<'closure, T> { +/// fn clone(&self) -> Jail<'closure, T> { +/// Jail(self.0, PhantomData) +/// } +/// } +/// +/// fn main() { +/// Jail::with(42, |token1| { +/// // this works and returns true: the clone has the same "identi= ty" +/// println!("{}", token1 =3D=3D token1.clone()); +/// Jail::with(42, |token2| { +/// // here the outer token remains accessible... +/// println!("{}", token1.get()); +/// // ... but the two are separate: this fails to compile: +/// println!("{}", token1 =3D=3D token2); +/// }); +/// }); +/// } +/// ``` +pub struct ParentInit<'init, T>( + &'init mut MaybeUninit, + PhantomData &'init ()>, +); =20 -impl<'a, T> ParentInit<'a, T> { +impl<'init, T> ParentInit<'init, T> { #[inline] - pub fn with(obj: &'a mut MaybeUninit, f: impl FnOnce(ParentInit<'a,= T>)) { - let parent_init =3D ParentInit(obj); + pub fn with(obj: &'init mut MaybeUninit, f: impl for<'id> FnOnce(Pa= rentInit<'id, T>)) { + let parent_init =3D ParentInit(obj, PhantomData); f(parent_init) } } --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437750; cv=none; d=zohomail.com; s=zohoarc; b=C8JTBXwgtPInrv0zqhFybI/hVfY6+9P7iLhvWyGcPNl8ZNuVR2LXsx9iuyWFWcLUJxaroe1IhDogk2nU+8GlzidZbZOck96VcFZbl6/WBefNs+0eelsBkXcwmVnY0DY8eJsRJkJvxQsfpCeUCfiALWtwxaHwBQDyf4CYYw9wPyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437750; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C7BJVylnGArdrB5PFjaOq4sJm/8iWC3XxxQA5l9UPfI=; b=L4gRnc1Hyfmcp1U7veWJ22HbsVkW6qsik93mgJ+gozcKJzfi0tEiT86ddHbv75d07CjagCaKToILGC5nh1+nwdBT4CMhTVSg2VJQrAP/Cv5U8EROP0Eu7ZveWkkWKAMmYEHFTj27SLVpFWs6oGMNH99T/esrb/jY5yOk+y59TsI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437750462452.6821184905481; Fri, 20 Jun 2025 09:42:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeo2-0006Ya-2a; Fri, 20 Jun 2025 12:41:35 -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 1uSenw-0006Xg-2x for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSent-0000GI-V1 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:27 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-7z7Vz1BmMraLFjCsQLl7pg-1; Fri, 20 Jun 2025 12:41:23 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-ad51ceda1d9so259076566b.1 for ; Fri, 20 Jun 2025 09:41:23 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a18cc09b5sm1599018a12.61.2025.06.20.09.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C7BJVylnGArdrB5PFjaOq4sJm/8iWC3XxxQA5l9UPfI=; b=hSiWisDEI4D1cNof8XRSb4+LFknKtonpajfl1rRQ8pNWwK7N4/p/E+eMByGb7VwkUN0CJO K6XtAf7pFcQG8KZFy+Faen8iF9vAAZepm3jptZ1wYX5RpgzPOIOyAtaFsY7lLx09SiRAy+ jah3NKNFB+lhSJViKFt7agAxy68lHR8= X-MC-Unique: 7z7Vz1BmMraLFjCsQLl7pg-1 X-Mimecast-MFC-AGG-ID: 7z7Vz1BmMraLFjCsQLl7pg_1750437682 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437681; x=1751042481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C7BJVylnGArdrB5PFjaOq4sJm/8iWC3XxxQA5l9UPfI=; b=g325PLVs/r8cxAZCb9reFUnddUbAeOrso5OshMkZUMJDyb1BvTZMFifqMCdTM2vqo4 idbj6D1eUGTXqKi1BAFLmnA87yNLOO8FRyBwrIU7RgZIJnmdOE1Zuvm6IA8eCEjd80cW pAoxW+rGCkpWu8YGq2Bf0CxX7W7yV6uVQ9XwTWmOD1QOhTbqA0bU1whGwb2L0427Pylv zlmGI+0HbzQh+5D0hbAT0zH0ahcoKuMBnMkqXGavWc93rhiP1ga3ZQWR8pdmarA5JQn5 Y+c77lWvRrjwTLSAub83yGRjIbUpGUlHRHu0Sve71cTtleuKRkKwWLY+k8S6d5FHb62f 7RzQ== X-Gm-Message-State: AOJu0YyVm79ECELBEzhTb1Xh3W1+2bUihu/S1FIzanQstQ1zhD8Vw1rl iugrzBC+wK1Avl2c0f0D3GzrJkL/RK2OwVudOLJSp/QHAU4Knk3n7UT/yT/7WmNOBMK+hqUfHQ5 CBnK1qKMImMAVO5zIL4nEXe43MTaAK959gN/tqlpkGuDYlIH1GCUK02qxvJbOvFZTqiQD9e0TYp ZY4/EYZCMgFbW998IFF6bAdY5N97Zec28jHLOQ2Qir X-Gm-Gg: ASbGncuJG9e+OyyU1bmRCdoJfvCBq47Bt1nlCmrZGoH6eAHQsW1kVLTOmQ/XhV3KmPQ uwrkZKjjnaCi0QJKAATO6MRrDIRjJD1iUmNtHXM9TzRorYz9jI2LlQ2c4STJhdnXMHwyrF9F3fY YLdNOxg4IDOSbMR+fdv9nyJvW8az0DpJUCbQKtHHwk1FM+IxTz84KU4vh6rZTqCm1dz7VuO/a0T k75HzXIm3SXhAz9ZQXnr1pOGSWHpc3HKGc67nk9TDBZvy+vEZJ0MMx9bEYtKKxZrJAyK2pZxdLt eDWRkt+hP6RZQuArgkzOEVvlxg== X-Received: by 2002:a05:6402:510a:b0:605:ff84:375b with SMTP id 4fb4d7f45d1cf-60a20cd7cb5mr2603892a12.16.1750437681149; Fri, 20 Jun 2025 09:41:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL+3f8wSqJ7mwf6do5rr9JU9ACzueU5G0IFa0fQn9mPA9g708elnL+bYcrPKrqFBZXhkEFdg== X-Received: by 2002:a05:6402:510a:b0:605:ff84:375b with SMTP id 4fb4d7f45d1cf-60a20cd7cb5mr2603823a12.16.1750437679923; Fri, 20 Jun 2025 09:41:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 09/24] rust: qom: change instance_init to take a ParentInit<> Date: Fri, 20 Jun 2025 18:40:37 +0200 Message-ID: <20250620164053.579416-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437751799116600 Content-Type: text/plain; charset="utf-8" This removes undefined behavior associated to writing to uninitialized fields, and makes it possible to remove "unsafe" from the instance_init implementation. However, the init function itself is still unsafe, because it must promise (as a sort as MaybeUninit::assume_init) that all fields have been initialized. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 34 ++++++++++------------ rust/hw/timer/hpet/src/device.rs | 16 ++++------- rust/qemu-api/src/memory.rs | 12 ++++---- rust/qemu-api/src/qdev.rs | 49 +++++++++++++++++++------------- rust/qemu-api/src/qom.rs | 9 ++++-- 5 files changed, 63 insertions(+), 57 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index be8387f6f2d..2d416cd9a3c 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -2,7 +2,7 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use std::{ffi::CStr, mem::size_of, ptr::addr_of_mut}; +use std::{ffi::CStr, mem::size_of}; =20 use qemu_api::{ chardev::{CharBackend, Chardev, Event}, @@ -11,9 +11,10 @@ memory::{hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder= }, prelude::*, qdev::{Clock, ClockEvent, DeviceImpl, DeviceState, Property, ResetType= , ResettablePhasesImpl}, - qom::{ObjectImpl, Owned, ParentField}, + qom::{ObjectImpl, Owned, ParentField, ParentInit}, static_assert, sysbus::{SysBusDevice, SysBusDeviceImpl}, + uninit_field_mut, vmstate::VMStateDescription, }; =20 @@ -163,7 +164,7 @@ impl PL011Impl for PL011State { impl ObjectImpl for PL011State { type ParentType =3D SysBusDevice; =20 - const INSTANCE_INIT: Option =3D Some(Self::init); + const INSTANCE_INIT: Option)> =3D Some(Self= ::init); const INSTANCE_POST_INIT: Option =3D Some(Self::post_init); const CLASS_INIT: fn(&mut Self::Class) =3D Self::Class::class_init::; } @@ -488,7 +489,7 @@ impl PL011State { /// `PL011State` type. It must not be called more than once on the same /// location/instance. All its fields are expected to hold uninitializ= ed /// values with the sole exception of `parent_obj`. - unsafe fn init(&mut self) { + unsafe fn init(mut this: ParentInit) { static PL011_OPS: MemoryRegionOps =3D MemoryRegionOpsB= uilder::::new() .read(&PL011State::read) .write(&PL011State::write) @@ -496,28 +497,23 @@ unsafe fn init(&mut self) { .impl_sizes(4, 4) .build(); =20 - // SAFETY: - // - // self and self.iomem are guaranteed to be valid at this point si= nce callers - // must make sure the `self` reference is valid. + // SAFETY: this and this.iomem are guaranteed to be valid at this = point MemoryRegion::init_io( - unsafe { &mut *addr_of_mut!(self.iomem) }, - addr_of_mut!(*self), + &mut uninit_field_mut!(*this, iomem), &PL011_OPS, "pl011", 0x1000, ); =20 - self.regs =3D Default::default(); + uninit_field_mut!(*this, regs).write(Default::default()); =20 - // SAFETY: - // - // self.clock is not initialized at this point; but since `Owned<_= >` is - // not Drop, we can overwrite the undefined value without side eff= ects; - // it's not sound but, because for all PL011State instances are cr= eated - // by QOM code which calls this function to initialize the fields,= at - // leastno code is able to access an invalid self.clock value. - self.clock =3D self.init_clock_in("clk", &Self::clock_update, Cloc= kEvent::ClockUpdate); + let clock =3D DeviceState::init_clock_in( + &mut this, + "clk", + &Self::clock_update, + ClockEvent::ClockUpdate, + ); + uninit_field_mut!(*this, clock).write(clock); } =20 const fn clock_update(&self, _event: ClockEvent) { diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/devi= ce.rs index 340ca1d355d..a281927781e 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -21,8 +21,8 @@ hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder, MEM= TXATTRS_UNSPECIFIED, }, prelude::*, - qdev::{DeviceImpl, DeviceMethods, DeviceState, Property, ResetType, Re= settablePhasesImpl}, - qom::{ObjectImpl, ObjectType, ParentField}, + qdev::{DeviceImpl, DeviceState, Property, ResetType, ResettablePhasesI= mpl}, + qom::{ObjectImpl, ObjectType, ParentField, ParentInit}, qom_isa, sysbus::{SysBusDevice, SysBusDeviceImpl}, timer::{Timer, CLOCK_VIRTUAL, NANOSECONDS_PER_SECOND}, @@ -697,7 +697,7 @@ fn set_counter_reg(&self, shift: u32, len: u32, val: u6= 4) { .set(self.counter.get().deposit(shift, len, val)); } =20 - unsafe fn init(&mut self) { + unsafe fn init(mut this: ParentInit) { static HPET_RAM_OPS: MemoryRegionOps =3D MemoryRegionOpsBuilder::::new() .read(&HPETState::read) @@ -707,18 +707,14 @@ unsafe fn init(&mut self) { .impl_sizes(4, 8) .build(); =20 - // SAFETY: - // self and self.iomem are guaranteed to be valid at this point si= nce callers - // must make sure the `self` reference is valid. MemoryRegion::init_io( - unsafe { &mut *addr_of_mut!(self.iomem) }, - addr_of_mut!(*self), + &mut uninit_field_mut!(*this, iomem), &HPET_RAM_OPS, "hpet", HPET_REG_SPACE_LEN, ); =20 - Self::init_timers(unsafe { &mut *((self as *mut Self).cast::>()) }); + Self::init_timers(&mut this); } =20 fn post_init(&self) { @@ -900,7 +896,7 @@ unsafe impl ObjectType for HPETState { impl ObjectImpl for HPETState { type ParentType =3D SysBusDevice; =20 - const INSTANCE_INIT: Option =3D Some(Self::init); + const INSTANCE_INIT: Option)> =3D Some(Self= ::init); const INSTANCE_POST_INIT: Option =3D Some(Self::post_init); const CLASS_INIT: fn(&mut Self::Class) =3D Self::Class::class_init::; } diff --git a/rust/qemu-api/src/memory.rs b/rust/qemu-api/src/memory.rs index 9ef2694bd62..e40fad6cf19 100644 --- a/rust/qemu-api/src/memory.rs +++ b/rust/qemu-api/src/memory.rs @@ -16,6 +16,7 @@ callbacks::FnCall, cell::Opaque, prelude::*, + uninit::MaybeUninitField, zeroable::Zeroable, }; =20 @@ -147,7 +148,7 @@ impl MemoryRegion { #[inline(always)] unsafe fn do_init_io( slot: *mut bindings::MemoryRegion, - owner: *mut Object, + owner: *mut bindings::Object, ops: &'static bindings::MemoryRegionOps, name: &'static str, size: u64, @@ -156,7 +157,7 @@ unsafe fn do_init_io( let cstr =3D CString::new(name).unwrap(); memory_region_init_io( slot, - owner.cast::(), + owner, ops, owner.cast::(), cstr.as_ptr(), @@ -166,16 +167,15 @@ unsafe fn do_init_io( } =20 pub fn init_io>( - &mut self, - owner: *mut T, + this: &mut MaybeUninitField<'_, T, Self>, ops: &'static MemoryRegionOps, name: &'static str, size: u64, ) { unsafe { Self::do_init_io( - self.0.as_mut_ptr(), - owner.cast::(), + this.as_mut_ptr().cast(), + MaybeUninitField::parent_mut(this).cast(), &ops.0, name, size, diff --git a/rust/qemu-api/src/qdev.rs b/rust/qemu-api/src/qdev.rs index 0610959f467..36f02fb57db 100644 --- a/rust/qemu-api/src/qdev.rs +++ b/rust/qemu-api/src/qdev.rs @@ -19,7 +19,7 @@ error::{Error, Result}, irq::InterruptSource, prelude::*, - qom::{ObjectClass, ObjectImpl, Owned}, + qom::{ObjectClass, ObjectImpl, Owned, ParentInit}, vmstate::VMStateDescription, }; =20 @@ -247,15 +247,9 @@ unsafe impl ObjectType for DeviceState { } qom_isa!(DeviceState: Object); =20 -/// Trait for methods exposed by the [`DeviceState`] class. The methods c= an be -/// called on all objects that have the trait `IsA`. -/// -/// The trait should only be used through the blanket implementation, -/// which guarantees safety via `IsA`. -pub trait DeviceMethods: ObjectDeref -where - Self::Target: IsA, -{ +/// Initialization methods take a [`ParentInit`] and can be called as +/// associated functions. +impl DeviceState { /// Add an input clock named `name`. Invoke the callback with /// `self` as the first parameter for the events that are requested. /// @@ -266,12 +260,15 @@ pub trait DeviceMethods: ObjectDeref /// which Rust code has a reference to a child object) it would be /// possible for this function to return a `&Clock` too. #[inline] - fn init_clock_in FnCall<(&'a Self::Target, ClockEvent)>>( - &self, + pub fn init_clock_in FnCall<(&'a T, ClockEve= nt)>>( + this: &mut ParentInit, name: &str, _cb: &F, events: ClockEvent, - ) -> Owned { + ) -> Owned + where + T::ParentType: IsA, + { fn do_init_clock_in( dev: &DeviceState, name: &str, @@ -287,10 +284,10 @@ fn do_init_clock_in( unsafe { let cstr =3D CString::new(name).unwrap(); let clk =3D bindings::qdev_init_clock_in( - dev.as_mut_ptr(), + dev.0.as_mut_ptr(), cstr.as_ptr(), cb, - dev.as_void_ptr(), + dev.0.as_void_ptr(), events.0, ); =20 @@ -307,12 +304,12 @@ fn do_init_clock_in( // SAFETY: the opaque is "this", which is indeed a pointer= to T F::call((unsafe { &*(opaque.cast::()) }, event)) } - Some(rust_clock_cb::) + Some(rust_clock_cb::) } else { None }; =20 - do_init_clock_in(self.upcast(), name, cb, events) + do_init_clock_in(unsafe { this.upcast_mut() }, name, cb, events) } =20 /// Add an output clock named `name`. @@ -324,16 +321,30 @@ fn do_init_clock_in( /// which Rust code has a reference to a child object) it would be /// possible for this function to return a `&Clock` too. #[inline] - fn init_clock_out(&self, name: &str) -> Owned { + pub fn init_clock_out(this: &mut ParentInit, name: &= str) -> Owned + where + T::ParentType: IsA, + { unsafe { let cstr =3D CString::new(name).unwrap(); - let clk =3D bindings::qdev_init_clock_out(self.upcast().as_mut= _ptr(), cstr.as_ptr()); + let dev: &mut DeviceState =3D this.upcast_mut(); + let clk =3D bindings::qdev_init_clock_out(dev.0.as_mut_ptr(), = cstr.as_ptr()); =20 let clk: &Clock =3D Clock::from_raw(clk); Owned::from(clk) } } +} =20 +/// Trait for methods exposed by the [`DeviceState`] class. The methods c= an be +/// called on all objects that have the trait `IsA`. +/// +/// The trait should only be used through the blanket implementation, +/// which guarantees safety via `IsA`. +pub trait DeviceMethods: ObjectDeref +where + Self::Target: IsA, +{ fn prop_set_chr(&self, propname: &str, chr: &Owned) { assert!(bql_locked()); let c_propname =3D CString::new(propname).unwrap(); diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs index 04d102591dc..e20ee014cb1 100644 --- a/rust/qemu-api/src/qom.rs +++ b/rust/qemu-api/src/qom.rs @@ -382,12 +382,15 @@ fn deref_mut(&mut self) -> &mut Self::Target { } =20 unsafe extern "C" fn rust_instance_init(obj: *mut bindings:= :Object) { - let mut state =3D NonNull::new(obj).unwrap().cast::(); + let mut state =3D NonNull::new(obj).unwrap().cast::>(); + // SAFETY: obj is an instance of T, since rust_instance_init // is called from QOM core as the instance_init function // for class T unsafe { - T::INSTANCE_INIT.unwrap()(state.as_mut()); + ParentInit::with(state.as_mut(), |parent_init| { + T::INSTANCE_INIT.unwrap()(parent_init); + }); } } =20 @@ -654,7 +657,7 @@ pub trait ObjectImpl: ObjectType + IsA { /// /// FIXME: The argument is not really a valid reference. `&mut /// MaybeUninit` would be a better description. - const INSTANCE_INIT: Option =3D None; + const INSTANCE_INIT: Option)> =3D None; =20 /// Function that is called to finish initialization of an object, once /// `INSTANCE_INIT` functions have been called. --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437733; cv=none; d=zohomail.com; s=zohoarc; b=FkUCH9QC05GNq5A0D1oTPkNo+u+9WHVvwY/IUg3hklBHghkhiAaaultEEr40tySpHjONFlAr92MdaCMTHpvRa0AkAZFx8boZnkyaiLcqgWXlOoE6gUbA9WBqMSfrVfGDh1LAnMd3/96KTASFp602le5xjGoCRenS6S03lUj961s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437733; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+h+zQtFRndjbbjZBH2HYw4tep2/IDavOmESW5qHH/2Y=; b=Mu4kuB8m7glT1/1c3fetnanVX2SLBUFBGQMcDunqCA1MV9dUac6C/JysFNixUIUmT4LhB7GgQhnRfu8z2OQU0dvRXl7H+EiSwxRRtGYAk93Vma6u7Lcma4WtHhGQPcuHGIU/2+VKcKohLVFBgmQtJNFBMegfMBPad2zx8PWZSvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437733780184.9814398706701; Fri, 20 Jun 2025 09:42:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeo2-0006YW-2R; Fri, 20 Jun 2025 12:41:34 -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 1uSenx-0006YD-HW for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenv-0000GP-UG for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:29 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-Er2TqbB0PVif3rkLlJ_N0g-1; Fri, 20 Jun 2025 12:41:24 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-60785397a37so1970158a12.2 for ; Fri, 20 Jun 2025 09:41:24 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053ecbe7dsm184578866b.49.2025.06.20.09.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+h+zQtFRndjbbjZBH2HYw4tep2/IDavOmESW5qHH/2Y=; b=hqNQU4fBm8H16aP/cQRNCC6sKo9yQhTAzKpxEEyHPtfe8+y8u+ZPZGclfKm0hEd9Mw5hED zJ5tygsmOF8RGpVO1+evfRLClodkhGPEie8/Yw17o5SOTWtyz20wj4b4f83F0enlS2SCtR uwfshuFEJHshKOdZlTeXmJWw/UIeIQI= X-MC-Unique: Er2TqbB0PVif3rkLlJ_N0g-1 X-Mimecast-MFC-AGG-ID: Er2TqbB0PVif3rkLlJ_N0g_1750437683 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437682; x=1751042482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+h+zQtFRndjbbjZBH2HYw4tep2/IDavOmESW5qHH/2Y=; b=Z2H9uecvfdCzFyOHsX9kjfk/+efy8WtynQgzCtUlVPLNhew1THLKMN5mRGXdDdugB7 3vMBwg11kLcC3/SZbSyp/qmlrb4Fcex+bAQ86QxriupUP4ttU5lC3qNabHDLo7t3ga5R OnQrZkg/j6PBsUx4dPNAjKoBJs2govQ985/j4l+lENgIuUpiyFsFdtweqdI4KWaD8Ckv 3XiGaCt0w7BK7ElfvNH7SaTJRnBR04YRhVc7+tJ+VLSPX/eWgCoDuGr2+d3WV/MtW7Cf Q3e2rhWFHrCeJu1aLGEGbjw9bkQM1ZH4qhq2P9fBXKMt7vuc7Acm9nwCcNeu4Y4AenCG iO+Q== X-Gm-Message-State: AOJu0YzxkcDqz5baNxg7pZbDlmY1bGZimOY6Z7zBr1Xg03dRvO9Bp74u FSNezghMv7hViBiCW7jSJRyOVJ/AykFDKPu8KNDO9WvCG5tCfbRfSbj/feRDtcm+9wv/kSj0Z8K bmzDNJ/qDwKqrqbqQmgxfbaZ1xYpKsHM7Rh/0o7Kkaj8Imtl6fEsWkYAruu6o4KGAyk2mfHUhuu 1kB38C9+6NdCx95+SHgT6rRwlHN3AxrFFhhTXs3Ic3 X-Gm-Gg: ASbGnctDXHUGbXRMYGgvcfYlqGIOvAQfnonkMAl+BnpkcyK1q5cYndOW7BKbO72c5jI Oap+0eIn3vlOA49faRh2uewp/YcIi3E8Qzc3r6EMBKEKVkjjKMIQLIKQuWVncDAjCJggK3kNihw /BSUUtyZq0DG4jaE68IhEOEIk3acUjga264pzSoyEOxBh4Hhd/QtfC1+kJPPXsChffpqEazrUwz e2I3iQTieRyZq39RVoumvMdTBWGvgZmdaf/2bFVpL7CpJH3aHRc38vw3AWm30eqUatSG3Hi8unc qGZleG9RH/wMJjpFLgoK/Vao+A== X-Received: by 2002:a17:907:3e0f:b0:ad5:d597:561e with SMTP id a640c23a62f3a-ae057c33162mr343999366b.56.1750437682448; Fri, 20 Jun 2025 09:41:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBt4goxrg26HjvrVHxQPAjVNFXay54U8lqmxWd+CFsofokxBMtYNKRhc8YRhMx84rlbMFvVA== X-Received: by 2002:a17:907:3e0f:b0:ad5:d597:561e with SMTP id a640c23a62f3a-ae057c33162mr343997066b.56.1750437681967; Fri, 20 Jun 2025 09:41:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 10/24] rust: prepare variable definitions for multiple bindgen invocations Date: Fri, 20 Jun 2025 18:40:38 +0200 Message-ID: <20250620164053.579416-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437735507116600 Content-Type: text/plain; charset="utf-8" When splitting the QEMU Rust bindings into multiple crates, the bindgen-generated structs also have to be split so that it's possible to add "impl" blocks (e.g. for Sync/Send or Default, or even for utility methods in cases such as VMStateFlags). Tweak various variable definitions in meson.build, to avoid naming conflicts once there will be multiple bindgen invocations. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- meson.build | 21 ++++++++++++--------- rust/meson.build | 2 +- rust/qemu-api/meson.build | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index ed60be2a2d0..19ffa9cb34c 100644 --- a/meson.build +++ b/meson.build @@ -4200,10 +4200,11 @@ foreach target_base_arch, config_base_arch : config= _base_arch_mak endforeach =20 if have_rust + bindings_incdir =3D include_directories('.', 'include') # We would like to use --generate-cstr, but it is only available # starting with bindgen 0.66.0. The oldest supported versions # is 0.60.x (Debian 12 has 0.60.1) which introduces --allowlist-file. - bindgen_args =3D [ + bindgen_args_common =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', @@ -4219,20 +4220,22 @@ if have_rust ] if not rustfmt.found() if bindgen.version().version_compare('<0.65.0') - bindgen_args +=3D ['--no-rustfmt-bindings'] + bindgen_args_common +=3D ['--no-rustfmt-bindings'] else - bindgen_args +=3D ['--formatter', 'none'] + bindgen_args_common +=3D ['--formatter', 'none'] endif endif if bindgen.version().version_compare('>=3D0.66.0') - bindgen_args +=3D ['--rust-target', '1.59'] + bindgen_args_common +=3D ['--rust-target', '1.59'] endif if bindgen.version().version_compare('<0.61.0') # default in 0.61+ - bindgen_args +=3D ['--size_t-is-usize'] + bindgen_args_common +=3D ['--size_t-is-usize'] else - bindgen_args +=3D ['--merge-extern-blocks'] + bindgen_args_common +=3D ['--merge-extern-blocks'] endif + + bindgen_args =3D [] c_enums =3D [ 'DeviceCategory', 'GpioPolarity', @@ -4264,13 +4267,13 @@ if have_rust # this case you must pass the path to `clang` and `libclang` to your bui= ld # command invocation using the environment variables CLANG_PATH and # LIBCLANG_PATH - bindings_rs =3D rust.bindgen( + _qemu_api_bindings_inc_rs =3D rust.bindgen( input: 'rust/wrapper.h', dependencies: common_ss.all_dependencies(), output: 'bindings.inc.rs', - include_directories: include_directories('.', 'include'), + include_directories: bindings_incdir, bindgen_version: ['>=3D0.60.0'], - args: bindgen_args, + args: bindgen_args_common + bindgen_args, ) subdir('rust') endif diff --git a/rust/meson.build b/rust/meson.build index 99ae7956cd0..e9f0879e296 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -33,5 +33,5 @@ if cargo.found() command: [config_host['MESON'], 'devenv', '--workdir', '@CURRENT_SOURCE_DIR@', cargo, 'fmt'], - depends: bindings_rs) + depends: _qemu_api_bindings_inc_rs) endif diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 33653b4a28e..64c04dfd74b 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -32,7 +32,7 @@ _qemu_api_rs =3D static_library( 'src/vmstate.rs', 'src/zeroable.rs', ], - {'.' : bindings_rs}, + {'.' : _qemu_api_bindings_inc_rs}, ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437800; cv=none; d=zohomail.com; s=zohoarc; b=EZLy0uX8IPsnJK1UybqzQxULc6nEcqDkSBXo2U8VZRdaUOdNaUXH+3mxq9Zb8695U3ZWWqk9An2Oc06dmQ1VSSX/JFXqS5ykf8Yirsn8TIrl+eGoM/CHkSbmc9nV7JykaiLys3Nx4DVvAq9X87WdXbCxOYOO5kkkjrPtRcW36pw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437800; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=R8LqKOiEsRIuredeKj7XdSZiPDaNUwtzibDGBjeZOjk=; b=LKEW9P88CsJ3jDc8QGWcjuH9fZ/QdZQdR6AAA709+oIwmOZDlSoMazsZiet5UGUruDN3T2WiadcaSqWcy+Dnx6JPqf5Xpns2hW99N6s3Q33Cnox2Pp35n08gY0JH/PKKsSYXFhBOJHi3NzbpgLGM9HhAlzbBgaNZg5NdaGJ629w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437800716948.0243228205567; Fri, 20 Jun 2025 09:43:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeo6-0006Zx-43; Fri, 20 Jun 2025 12:41:38 -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 1uSeo2-0006Yt-4y for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSenx-0000Gf-Kq for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:33 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-315-hUnglG2MMuenMqGTSepNLg-1; Fri, 20 Jun 2025 12:41:27 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-addcea380fcso135777066b.0 for ; Fri, 20 Jun 2025 09:41:27 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053e809d4sm184987966b.26.2025.06.20.09.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R8LqKOiEsRIuredeKj7XdSZiPDaNUwtzibDGBjeZOjk=; b=jADsa4a3RXR62HrF/Nczknh8a72EVp/nOGM6mdcNNiE1lN0hVKkl8af15Ijfzk7YDApBPr 3xAfyBzt3MBUtbMniHTxS8iGbr1T0RJ17+v5H0vIprf+4XcI1xOAFZzQRl3jxoTVb5X9BJ G1LWWpzME5Fc/kDlkYiWN6XcmlaNFrY= X-MC-Unique: hUnglG2MMuenMqGTSepNLg-1 X-Mimecast-MFC-AGG-ID: hUnglG2MMuenMqGTSepNLg_1750437686 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437686; x=1751042486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R8LqKOiEsRIuredeKj7XdSZiPDaNUwtzibDGBjeZOjk=; b=X/HNCaISg8CY1fAJjg5yvDNLUV1UF73yBWOpq3VY3Ti3IN51UvnltS0payqhGpAoGZ br15odiumkmv7fE9q9zBmrKDpZ+8on62iDyov1T+VmAusmjvwh1FfpYxc7lc9f0OEhz8 SNV4uUj295AD8J94bUFDc3fl5/q6Us/A8+yR/ipzMQhxJudVr7WoFzxbqNTF6SXJM/0/ AkbALbKw89mtHZ7bT+/lB+v8YQ2XmlnNSA2gDmUAzSSkRbjPBbo3GynECg1o+Yrt2Hhk 4VT7YdM4IlWoNZqcwvrjV5gOB1Q/lvFwKhmfZL8AmVmOrN6PnlBJQXocgYEkKjnmUb12 outw== X-Gm-Message-State: AOJu0Yy8wmSixbyVes4dBQQYpZjxRSb0mDK6ERn1q45Eoxe00EX9rj4a QqM3ZfCO8Rw9teFkjxZgBadSiEknO1reh6PjaMiSdwwnYGrMEqbBke5HFwXZTEbozGxbKV4udE6 L7LX1uaDIrikXyoXuUI6f0sj+RXdcJTPZyYbMtgSjKJhmML9Z77DtypPce4RkayOluSQbwqA+dz fQsTiNA3OZNd+IjgfeM+S//2nlbmHddMHgdIXNmYgg X-Gm-Gg: ASbGncvbYA2F25OK8JIExVaz/ij1BuBkGmfitbifJXLjBjOZBXKR4rmD/pH2KyA0N9c eRpapphfuPXW2ycrmj+owAaMlaJWSJAURd1/g0iK47nhp3E3Y3EYvBPRCwckpuQHFKQZTIfcWv4 9zDkfpPIcSDenD7ZuJidZnNhHbtA8UHPImc+CpBuSCMf/sbizAPnpsdmnaNcdK+SIhgrv6mpQmw rglC/qP+ZYAkj8mHhCKkFAwxp39Vb6xR+vx3punw+O+Lk1lTgLiZFSaGVlNBMVLnZEMYqDfmcJZ zw1+6zbTzuCyAYfQI4CiMTKScQ== X-Received: by 2002:a17:907:3c82:b0:ad8:914b:7d0b with SMTP id a640c23a62f3a-ae0579cd940mr362858166b.11.1750437685592; Fri, 20 Jun 2025 09:41:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu/17NnkqKbjAXxzlATiQ2kZziRH1iekLIrNK3R4CQv64r90Bgl7KbERmN/niOUR/dgFtbew== X-Received: by 2002:a17:907:3c82:b0:ad8:914b:7d0b with SMTP id a640c23a62f3a-ae0579cd940mr362855566b.11.1750437685074; Fri, 20 Jun 2025 09:41:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 11/24] rust: move rust.bindgen to qemu-api crate Date: Fri, 20 Jun 2025 18:40:39 +0200 Message-ID: <20250620164053.579416-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437802168116600 Content-Type: text/plain; charset="utf-8" Once qemu-api is split in multiple crates, each of them will have its own invocation of bindgen. There cannot be only one, because there are occasional "impl" blocks for the bindgen-generated structs (e.g. VMStateFlags or QOM classes) that have to reside in the same crate as the bindgen-generated code. For now, prepare for this new organization by invoking bindgen within the qemu-api crate's build definitions; it's also a much better place to list enums that need specific treatment from bindgen. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- meson.build | 41 ----------------------------------- rust/{ =3D> qemu-api}/wrapper.h | 0 rust/meson.build | 4 +++- rust/qemu-api/build.rs | 2 +- rust/qemu-api/meson.build | 41 +++++++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 43 deletions(-) rename rust/{ =3D> qemu-api}/wrapper.h (100%) diff --git a/meson.build b/meson.build index 19ffa9cb34c..4676908dbb2 100644 --- a/meson.build +++ b/meson.build @@ -4234,47 +4234,6 @@ if have_rust else bindgen_args_common +=3D ['--merge-extern-blocks'] endif - - bindgen_args =3D [] - c_enums =3D [ - 'DeviceCategory', - 'GpioPolarity', - 'MachineInitPhase', - 'MemoryDeviceInfoKind', - 'MigrationPolicy', - 'MigrationPriority', - 'QEMUChrEvent', - 'QEMUClockType', - 'ResetType', - 'device_endian', - 'module_init_type', - ] - foreach enum : c_enums - bindgen_args +=3D ['--rustified-enum', enum] - endforeach - c_bitfields =3D [ - 'ClockEvent', - 'VMStateFlags', - ] - foreach enum : c_bitfields - bindgen_args +=3D ['--bitfield-enum', enum] - endforeach - - # TODO: Remove this comment when the clang/libclang mismatch issue is so= lved. - # - # Rust bindings generation with `bindgen` might fail in some cases where= the - # detected `libclang` does not match the expected `clang` version/target= . In - # this case you must pass the path to `clang` and `libclang` to your bui= ld - # command invocation using the environment variables CLANG_PATH and - # LIBCLANG_PATH - _qemu_api_bindings_inc_rs =3D rust.bindgen( - input: 'rust/wrapper.h', - dependencies: common_ss.all_dependencies(), - output: 'bindings.inc.rs', - include_directories: bindings_incdir, - bindgen_version: ['>=3D0.60.0'], - args: bindgen_args_common + bindgen_args, - ) subdir('rust') endif =20 diff --git a/rust/wrapper.h b/rust/qemu-api/wrapper.h similarity index 100% rename from rust/wrapper.h rename to rust/qemu-api/wrapper.h diff --git a/rust/meson.build b/rust/meson.build index e9f0879e296..331f11b7e72 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -20,6 +20,8 @@ proc_macro2_rs_native =3D dependency('proc-macro2-1-rs', = native: true) =20 qemuutil_rs =3D qemuutil.partial_dependency(link_args: true, links: true) =20 +genrs =3D [] + subdir('qemu-api-macros') subdir('bits') subdir('qemu-api') @@ -33,5 +35,5 @@ if cargo.found() command: [config_host['MESON'], 'devenv', '--workdir', '@CURRENT_SOURCE_DIR@', cargo, 'fmt'], - depends: _qemu_api_bindings_inc_rs) + depends: genrs) endif diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs index 1e720641d2b..7849486c1ba 100644 --- a/rust/qemu-api/build.rs +++ b/rust/qemu-api/build.rs @@ -14,7 +14,7 @@ fn main() -> Result<()> { let path =3D env::var("MESON_BUILD_ROOT") .unwrap_or_else(|_| format!("{}/src", env!("CARGO_MANIFEST_DIR"))); =20 - let file =3D format!("{path}/bindings.inc.rs"); + let file =3D format!("{path}/rust/qemu-api/bindings.inc.rs"); let file =3D Path::new(&file); if !Path::new(&file).exists() { panic!(concat!( diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 64c04dfd74b..5b8c7e5e8d5 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -7,6 +7,47 @@ if get_option('debug_mutex') _qemu_api_cfg +=3D ['--cfg', 'feature=3D"debug_cell"'] endif =20 +c_enums =3D [ + 'DeviceCategory', + 'GpioPolarity', + 'MachineInitPhase', + 'MemoryDeviceInfoKind', + 'MigrationPolicy', + 'MigrationPriority', + 'QEMUChrEvent', + 'QEMUClockType', + 'ResetType', + 'device_endian', + 'module_init_type', +] +_qemu_api_bindgen_args =3D [] +foreach enum : c_enums + _qemu_api_bindgen_args +=3D ['--rustified-enum', enum] +endforeach +c_bitfields =3D [ + 'ClockEvent', + 'VMStateFlags', +] +foreach enum : c_bitfields + _qemu_api_bindgen_args +=3D ['--bitfield-enum', enum] +endforeach + +# TODO: Remove this comment when the clang/libclang mismatch issue is solv= ed. +# +# Rust bindings generation with `bindgen` might fail in some cases where t= he +# detected `libclang` does not match the expected `clang` version/target. = In +# this case you must pass the path to `clang` and `libclang` to your build +# command invocation using the environment variables CLANG_PATH and +# LIBCLANG_PATH +_qemu_api_bindings_inc_rs =3D rust.bindgen( + input: 'wrapper.h', + dependencies: common_ss.all_dependencies(), + output: 'bindings.inc.rs', + include_directories: bindings_incdir, + bindgen_version: ['>=3D0.60.0'], + args: bindgen_args_common + _qemu_api_bindgen_args, + ) + _qemu_api_rs =3D static_library( 'qemu_api', structured_sources( --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437799; cv=none; d=zohomail.com; s=zohoarc; b=G4uC7V3D1wPZ4Exyfg2VJfeJncWBghgUjz3YchWhyRrd8Nl+C3qhGGpuZzhjIwQCXkXEA56QfObDQFURO5F10Dxg7+GuhY+FtiVFrIUrq2VzAY3BkBnYpEqopjFkKyG/fB9CoupVxnNhyR9/vCZ1m4dqJUUPbiUQyNrMkjT2U4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437799; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wUb33t/Ddy47dv9hj5zcbOKfPHOBFw+S7xvVBLDYZiQ=; b=Ikmqx49EAv4FsFLetZIewArgf1csPCUMhE2yrtbmCYawsgN5Z6vB0EwAToXj3xi3UDGFB0GiwJYy3fWRIQyDSkWi/xxfJaerLWS3FP1IzgF4hTyZ8r1bnANfdy7d+afNMYwirutQ6Y/UYoJIBvyJNoGLr63eBM6Msb+bfZSjYeE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437799194635.5455770039822; Fri, 20 Jun 2025 09:43:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeo7-0006aF-2E; Fri, 20 Jun 2025 12:41:39 -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 1uSeo4-0006Zj-TH for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeo1-0000Gv-Ty for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:35 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-B6Z7r6faNzCzAuvZBIm-cg-1; Fri, 20 Jun 2025 12:41:31 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-6023d9a86ffso1283070a12.3 for ; Fri, 20 Jun 2025 09:41:30 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae05408301fsm188247066b.96.2025.06.20.09.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wUb33t/Ddy47dv9hj5zcbOKfPHOBFw+S7xvVBLDYZiQ=; b=SkPwrtrGdvblv2uMi8SQsoZCXzdoXqWaljpQku+yKw6va7W099rHn3Oj6twE7uEJ+xT1de 7hxuGS9szXL55MFEG3qDwG3fOBKmiHLvHdUt/PtKItDmNipWuSxDI2p5nPdTzGfRVGU81o vWbN5Onbi92q7egUe+b5zNiHRYSwv2I= X-MC-Unique: B6Z7r6faNzCzAuvZBIm-cg-1 X-Mimecast-MFC-AGG-ID: B6Z7r6faNzCzAuvZBIm-cg_1750437690 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437689; x=1751042489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wUb33t/Ddy47dv9hj5zcbOKfPHOBFw+S7xvVBLDYZiQ=; b=CXiHHGL3bEyOUQgkYgeSi1V9y+x4ZieJHt+riTpfe72bYErm7YNU2HISWKnMru8xDP GQ9mSIoSaTOVdRL3WVtQmuUnQbmyk8JM+f3wwfdn21jcNSoSb+B085gv2ivDcpjYTCrI KYpm6IKk7R8sQnlQFkeAzolOwtieVnkRbqlcWa0A+wJMS3zeqGEX5IlwDuI3i7kcyEqa b3tY5ovRRxb9SsMtIbpEFTn56aSXh6av3djTVGc2eOHIydqBqheqW8XyIPQmRxnHrty6 iult+VF/FPIO8nezWOVD8zPrjsOnpqC6ywP+lnEoTYA9fBVAR1SxQhQ3pIbUlFhwwRxY ArZg== X-Gm-Message-State: AOJu0Yx/A8sjyljZbm/OfzNKNgYTV0+uC9p2ihVXcYJ7pj/KC/Ks2LqE mL+RYsnmsU/lakXq4SnFs9suNzpK3XcRd3h4MpVuHXWfzvnWfJe22SdI5dpnCF0yaqSEoxnNTp8 wRWeN1SWXGzZKUcX2Y7D66RbZlVjgGF9i8GljVWF9fFIB8LIGbCFSrfrLWaIkKWJdLu8lEXaCIx d8G2YISwEE9Jmdy9FtfQ/UWYbRU8ufLxl85yU0fQRe X-Gm-Gg: ASbGncsd0T7JQwNbsFc/2cw/IkUVOKX8Dnhl7AMlCJxViC7+RVFOOLlQuH2PXPwEJKD PlXTomg3NZ9y5gncTfRxwVWbQq9RwmSkm9zP4PgyxwR7ebVU/0nshFF313YBiLfTpudoZTLA5n6 wFnjMbCrjv6epaAbCU2uxjQ+LHiQJ0Gv/QQk65yFmhVVBYYdQJb5KkLQMAtYvofN1YH1WxsC3xW X0NZtks2wMuP4svVHrUFryLYnPJhzuLhEfll8AVwVYbdvHnkNEujfxreabkQMZOjttoQ4X5eb5U p1p4LHNerFRewMNSyZtmGEdcTg== X-Received: by 2002:a17:906:dc95:b0:ae0:16db:1b62 with SMTP id a640c23a62f3a-ae057c8e314mr344551866b.59.1750437688702; Fri, 20 Jun 2025 09:41:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk5NiQkEvw3hQWWNAuMQ4R/Inc7qCXwqsyHVrmecTMyVzC4XHagtWPMwSTcTgWwRx08DL69g== X-Received: by 2002:a17:906:dc95:b0:ae0:16db:1b62 with SMTP id a640c23a62f3a-ae057c8e314mr344548666b.59.1750437688076; Fri, 20 Jun 2025 09:41:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow Subject: [PULL 12/24] rust/qemu-api: Add initial logging support based on C API Date: Fri, 20 Jun 2025 18:40:40 +0200 Message-ID: <20250620164053.579416-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437800107116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow A log_mask_ln!() macro is provided which expects similar arguments as the C version. However, the formatting works as one would expect from Rust. To maximize code reuse the macro is just a thin wrapper around qemu_log(). Also, just the bare minimum of logging masks is provided which should suffice for the current use case of Rust in QEMU. Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20250615112037.11992-2-shentey@gmail.com Signed-off-by: Paolo Bonzini --- docs/devel/rust.rst | 1 + rust/qemu-api/wrapper.h | 2 + rust/qemu-api/meson.build | 1 + rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/log.rs | 73 ++++++++++++++++++++++++++++++++++++ rust/qemu-api/src/prelude.rs | 2 + 6 files changed, 80 insertions(+) create mode 100644 rust/qemu-api/src/log.rs diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst index 47e9677fcb0..dc8c44109e1 100644 --- a/docs/devel/rust.rst +++ b/docs/devel/rust.rst @@ -162,6 +162,7 @@ module status ``errno`` complete ``error`` stable ``irq`` complete +``log`` proof of concept ``memory`` stable ``module`` complete ``qdev`` stable diff --git a/rust/qemu-api/wrapper.h b/rust/qemu-api/wrapper.h index 6060d3ba1ab..15a1b19847f 100644 --- a/rust/qemu-api/wrapper.h +++ b/rust/qemu-api/wrapper.h @@ -48,6 +48,8 @@ typedef enum memory_order { #endif /* __CLANG_STDATOMIC_H */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/log-for-trace.h" #include "qemu/module.h" #include "qemu-io.h" #include "system/system.h" diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 5b8c7e5e8d5..a090297c458 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -62,6 +62,7 @@ _qemu_api_rs =3D static_library( 'src/errno.rs', 'src/error.rs', 'src/irq.rs', + 'src/log.rs', 'src/memory.rs', 'src/module.rs', 'src/prelude.rs', diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index c78198f0f41..86dcd8ef17a 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -21,6 +21,7 @@ pub mod errno; pub mod error; pub mod irq; +pub mod log; pub mod memory; pub mod module; pub mod qdev; diff --git a/rust/qemu-api/src/log.rs b/rust/qemu-api/src/log.rs new file mode 100644 index 00000000000..d6c3d6c1b63 --- /dev/null +++ b/rust/qemu-api/src/log.rs @@ -0,0 +1,73 @@ +// Copyright 2025 Bernhard Beschow +// SPDX-License-Identifier: GPL-2.0-or-later + +//! Bindings for QEMU's logging infrastructure + +#[repr(u32)] +/// Represents specific error categories within QEMU's logging system. +/// +/// The `Log` enum provides a Rust abstraction for logging errors, corresp= onding +/// to a subset of the error categories defined in the C implementation. +pub enum Log { + /// Log invalid access caused by the guest. + /// Corresponds to `LOG_GUEST_ERROR` in the C implementation. + GuestError =3D crate::bindings::LOG_GUEST_ERROR, + + /// Log guest access of unimplemented functionality. + /// Corresponds to `LOG_UNIMP` in the C implementation. + Unimp =3D crate::bindings::LOG_UNIMP, +} + +/// A macro to log messages conditionally based on a provided mask. +/// +/// The `log_mask_ln` macro checks whether the given mask matches the curr= ent +/// log level and, if so, formats and logs the message. It is the Rust +/// counterpart of the `qemu_log_mask()` macro in the C implementation. +/// +/// # Parameters +/// +/// - `$mask`: A log level mask. This should be a variant of the `Log` enu= m. +/// - `$fmt`: A format string following the syntax and rules of the `forma= t!` +/// macro. It specifies the structure of the log message. +/// - `$args`: Optional arguments to be interpolated into the format strin= g. +/// +/// # Example +/// +/// ``` +/// use qemu_api::{log::Log, log_mask_ln}; +/// +/// let error_address =3D 0xbad; +/// log_mask_ln!(Log::GuestError, "Address 0x{error_address:x} out of rang= e"); +/// ``` +/// +/// It is also possible to use printf-style formatting, as well as having a +/// trailing `,`: +/// +/// ``` +/// use qemu_api::{log::Log, log_mask_ln}; +/// +/// let error_address =3D 0xbad; +/// log_mask_ln!( +/// Log::GuestError, +/// "Address 0x{:x} out of range", +/// error_address, +/// ); +/// ``` +#[macro_export] +macro_rules! log_mask_ln { + ($mask:expr, $fmt:tt $($args:tt)*) =3D> {{ + // Type assertion to enforce type `Log` for $mask + let _: Log =3D $mask; + + if unsafe { + (::qemu_api::bindings::qemu_loglevel & ($mask as std::os::raw:= :c_int)) !=3D 0 + } { + let formatted_string =3D format!("{}\n", format_args!($fmt $($= args)*)); + let c_string =3D std::ffi::CString::new(formatted_string).unwr= ap(); + + unsafe { + ::qemu_api::bindings::qemu_log(c_string.as_ptr()); + } + } + }}; +} diff --git a/rust/qemu-api/src/prelude.rs b/rust/qemu-api/src/prelude.rs index 43bfcd5fcab..8f9e23ee2c5 100644 --- a/rust/qemu-api/src/prelude.rs +++ b/rust/qemu-api/src/prelude.rs @@ -11,6 +11,8 @@ =20 pub use crate::errno; =20 +pub use crate::log_mask_ln; + pub use crate::qdev::DeviceMethods; =20 pub use crate::qom::InterfaceType; --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437823; cv=none; d=zohomail.com; s=zohoarc; b=SaS6EP7cjh1Jv4muVY+TPddx2Fj+gWoCUAyNrRsebPmwcIoYHQRAAi335bzJFk209pZfvpWmZ603HA+wQ/Jyx/jcZgg5ptm3s5FLDJHzrmnmWLeVrPq9afdqtx/P2cb7gA9H0hmXEHbsHz79Ljw8c+QX/YUY8ZLCTpVctlUAMjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437823; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m09gyrXVI69lguFqQqhapy6DhI44HdNH8ReXpoV/H/Y=; b=ZLAK9bZ8sa4FVFV7suz9mQYi2JbYct2IrQ7FTlhzzWYJvP4y9Au3QBRBlHa6oAWAXdzrPs1vxOpgW8Lw6FSGQlOKFU2ylXyyxgM/zBhfySYQflmBsNckJhihUjBlkai630kohhqWKyipEpNAckRJmJkQUh+sk5jqt5Nn0X7iABQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437823796440.57641197147734; Fri, 20 Jun 2025 09:43:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoA-0006bH-8Z; Fri, 20 Jun 2025 12:41: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 1uSeo6-0006aG-Fw for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeo4-0000HB-Kp for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:38 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-qhjya6dHMq-RFeI4ZBak_A-1; Fri, 20 Jun 2025 12:41:32 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-60785397a37so1970302a12.2 for ; Fri, 20 Jun 2025 09:41:32 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae05408306fsm183794066b.84.2025.06.20.09.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m09gyrXVI69lguFqQqhapy6DhI44HdNH8ReXpoV/H/Y=; b=WQwZ/61/zHzjVHubL9Fs8RmrJ7Sb5IMtGknBuHKuREbnSt2psNz1ICuTcO4QTr+8M+PNWt wYRfvvcYcYJ6D7xh5cdLuVGkqUpKK4ebJWnw+n7kJ/4bw/TN+Ydi3ghxBdq8qwD9CLMd6e xeDoOAvSPvBZ5GLsvsfjwgniFYLhXHI= X-MC-Unique: qhjya6dHMq-RFeI4ZBak_A-1 X-Mimecast-MFC-AGG-ID: qhjya6dHMq-RFeI4ZBak_A_1750437692 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437691; x=1751042491; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m09gyrXVI69lguFqQqhapy6DhI44HdNH8ReXpoV/H/Y=; b=wTkWeENavxo+9WH9PsM574yU79JiM7TuM8rdPlWrrw0ZcAXzKty7TyfrHRCcsWVmct ZysJisV3JW1bNivQC9qZBLg79c30hDYzqQ7kFPh/AlxzNlPe4kpi9ZcslGGA+JhdrSKb mTWIBGWr/O4rwzeW43MoFXArf4bMS7ysxRGDQsW8D4CnZYyJ1993yMk66AYCUzWUYU9d BIFblbjSX1GllrbiVVgwdI2BASMBWjl3LtXnOGFtagommjGbRMOb1yyJYraiVnQXbubj iMr/RxaDi0ra4mJVtWKfsNcn1FSXrBHzvcAvSY8snwoP5lTZWRHSAGCG/ZyXiRMq41DT hvvw== X-Gm-Message-State: AOJu0YxRcO8HFf5KFmptE3Vdn1a+FRRFWI/96QpHv9WH+GurRHKrEEGh IB5a9BSP43ob4NrjGvhQB+crT7zUvuKVjyUenrKNJIkshYBeYZ//EO+yKy1DJaJBQfAhVBEMUra xZSo63kviG6WDgzp2CUY9it9NEo8xhPSKVfSUdnXcxtfdJZQa4CioSx2GRCVyTHMTA0+3x5kJaP kmfp1rqKklCIW+4K1EvhOSJubTVSfseJtxI22sR+0Z X-Gm-Gg: ASbGncsGcsM2km2zoi7Ynm096GyskuHFSu+JR8kZTumF1ksk4KQnPYS/IDDcPTKoGqv IRHrFUPGxZg5etKdlpSoYorGiqU176tEod8/GMawthLJM/sFTvgCrata511TwASiX+KkmfHSAIR arpNkS+dHhQzkI37DVKgBxEK6NuwsBS5CE5OYtMbl7738Ho9QKxvbktWbI3MAs89+QHTzuOvcTo Xd/xhD48iv+Fbdp5WrEytkxpNjHtWobB3TIFb1KCptLWb4DxUJMUhhEdNbDmX3zxjGveyLo8LgH Smt/mYUUxiYFWKiGeVxDuKf2mg== X-Received: by 2002:a05:6402:3546:b0:607:19a6:9f1d with SMTP id 4fb4d7f45d1cf-60a1cd3206dmr3413679a12.14.1750437691226; Fri, 20 Jun 2025 09:41:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGR614FVv/R2yCgf5Ei0LXIAbyWz9IHUQeJln+17GXwTuLoGBhTb4d1DESDCiOMg1d5qLISGg== X-Received: by 2002:a05:6402:3546:b0:607:19a6:9f1d with SMTP id 4fb4d7f45d1cf-60a1cd3206dmr3413645a12.14.1750437690794; Fri, 20 Jun 2025 09:41:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow Subject: [PULL 13/24] rust: pl011: Implement logging Date: Fri, 20 Jun 2025 18:40:41 +0200 Message-ID: <20250620164053.579416-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437826376116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Now that there is logging support in Rust for QEMU, use it in the pl011 device. Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20250615112037.11992-3-shentey@gmail.com Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 2d416cd9a3c..92dc295540e 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -8,6 +8,8 @@ chardev::{CharBackend, Chardev, Event}, impl_vmstate_forward, irq::{IRQState, InterruptSource}, + log::Log, + log_mask_ln, memory::{hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder= }, prelude::*, qdev::{Clock, ClockEvent, DeviceImpl, DeviceState, Property, ResetType= , ResettablePhasesImpl}, @@ -276,8 +278,7 @@ pub(self) fn write( DMACR =3D> { self.dmacr =3D value; if value & 3 > 0 { - // qemu_log_mask(LOG_UNIMP, "pl011: DMA not implemente= d\n"); - eprintln!("pl011: DMA not implemented"); + log_mask_ln!(Log::Unimp, "pl011: DMA not implemented"); } } } @@ -534,7 +535,7 @@ fn read(&self, offset: hwaddr, _size: u32) -> u64 { u64::from(device_id[(offset - 0xfe0) >> 2]) } Err(_) =3D> { - // qemu_log_mask(LOG_GUEST_ERROR, "pl011_read: Bad offset = 0x%x\n", (int)offset); + log_mask_ln!(Log::GuestError, "PL011State::read: Bad offse= t {offset}"); 0 } Ok(field) =3D> { @@ -566,7 +567,10 @@ fn write(&self, offset: hwaddr, value: u64, _size: u32= ) { .borrow_mut() .write(field, value as u32, &self.char_backend); } else { - eprintln!("write bad offset {offset} value {value}"); + log_mask_ln!( + Log::GuestError, + "PL011State::write: Bad offset {offset} value {value}" + ); } if update_irq { self.update(); --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437750; cv=none; d=zohomail.com; s=zohoarc; b=V/KFXoJEw+FrXkmVB6JUZUqfvHfK6R/tTO+xkGr/z1rn7zFVnYAe8MbytfdaDPd+yewm63g8vXTHUndPwg8OhEbUPXmMcmlBv0os0yvxthj/GTYu9/BcU3eVF6jjPKpSFKuXdH/A31/6Uk9vAzQc7K0LgtVUwlOVsG9RllBX7FQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437750; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XMGhYnZFHX5IefyrfK9nBnHDbZhTF5W9KaGEmJ1RYIY=; b=QtqCuaZXjjBiMqOFJs5zv0UKyEuz1Ya2NZkAIschuftOyIHLQPyoNEW/dtyfgDuD61RX9JH25AF3bzHlxGtxFx5RuUs+eD+Eyp27/irs/7f1TiV+WPPV2Ii3tobgNsYMm6zzvM9YyhyOvMKnfOEpP7xI/XmQfonphxA4YYHYhfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175043775019411.913076070202806; Fri, 20 Jun 2025 09:42:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoC-0006cD-6b; Fri, 20 Jun 2025 12:41: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 1uSeo7-0006ar-QX for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeo6-0000Hp-7u for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:39 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-uQgv9LSVMKmIfdX1XISmbA-1; Fri, 20 Jun 2025 12:41:36 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-acb8f9f58ebso164354766b.2 for ; Fri, 20 Jun 2025 09:41:35 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053e801ccsm185328666b.7.2025.06.20.09.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XMGhYnZFHX5IefyrfK9nBnHDbZhTF5W9KaGEmJ1RYIY=; b=Pb2iN/kGRtq/jtBEO2B8WzHD34aB6Qj55Kp4YNlTKNcQWcqm5sKHCaLn7dKgRt0U8Fgo9T lFSmcbvSL9n+6ishB35y6D3WAhewYAmPW8Ew+a1IDJoLTm2WLBjJ5bA5032Ow/Q3wbpb7X CzC8iKPOkirxj7Yty3TzHG9FM2OOYnw= X-MC-Unique: uQgv9LSVMKmIfdX1XISmbA-1 X-Mimecast-MFC-AGG-ID: uQgv9LSVMKmIfdX1XISmbA_1750437695 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437694; x=1751042494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XMGhYnZFHX5IefyrfK9nBnHDbZhTF5W9KaGEmJ1RYIY=; b=nMn5Plr5EyMtCnoNW4qEgsDyD6YyFInejsfkD4pLYYxFU6JfKJzg68llilhOF/ei7d +7aw22222w++/Fuhha0VDwFzK/OfpbN0nPaPOFiitTcmlumuqT9/mdA0T/0FLcIurRSW Wgxf82uFEa1h+vkEFJbYlI/jTRNNBoMVvIjn2HAnRkL+jWxJ48HfeWqS2Q2PKkjn6mXA iVd1Tskg/4pBHCf4iZGx3w4J2atbtghnK+EArG0XqZDy90T/OCDYHQjGqkeLOSBhtcbi YIfYRv2Kg5d0Lu+c4U6emA+wapUdjcx/zfg0wgwNzMcuRHKpcrOyUGIoQAPE2vQET2Dg SsNA== X-Gm-Message-State: AOJu0YwWZ3tK5CPbKAbTN1CLF4bry0SGJTSdeqrDPqw3gSIZSZPfXA0b o+4MCgsFw+4dGI123XabFQYnSitiEzGqSn3iWSfuJ4h7GY50t8exQaXwQ9Uf01ycXfny2Y2ewyZ tDIB0ozy129jxvQwvziqv0Bi0gWuQoz+CoNXAzk4BodUNunOEATT1vRnMdzGrMUJV0ubydgpH79 1b1e3wxYCJXqKRQjWsXMNOv8K3vTlxO8TSbxOb6tcJ X-Gm-Gg: ASbGnctDhC9a2x+ayK0Zic0Zoek9CkyJ9xxNlUPB/9ieCDHhjbKfaIyDoG/X26kcE3h HKMORQzHsoFpabdezg5V0aRBtFXm+D58kSmd7BETalZyQ4HmKgnWkpoD0uqBRup+5l26jpxELOS nXlU+qBZ2CFcpSpMTGkE1dLWWA2rvRh2FAi41hif+jjmVXoYqp4vvNQf6QsgEdtYLWQLedXa2js h8UKIahaIKYC0q5++dfINqtwXIrfNgWUprQsZHKjJUaupKR44Hab30mKXH1kpeq1MmpoQ0IQBOT jfzegZljGEHUVwkfpneRUAqsGQ== X-Received: by 2002:a17:907:db15:b0:ade:8d5a:cf37 with SMTP id a640c23a62f3a-ae057f2166emr335957566b.44.1750437693806; Fri, 20 Jun 2025 09:41:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPQJ5Dtib/VLX65pHAXxYw1y9ZXtr1SOopos6qQ00HYRWazdyrZ5sEuoeOrcGhyDruN2uNsg== X-Received: by 2002:a17:907:db15:b0:ade:8d5a:cf37 with SMTP id a640c23a62f3a-ae057f2166emr335955366b.44.1750437693353; Fri, 20 Jun 2025 09:41:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow Subject: [PULL 14/24] rust: pl011: Add missing logging to match C version Date: Fri, 20 Jun 2025 18:40:42 +0200 Message-ID: <20250620164053.579416-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437751364116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Co-developed-by: Paolo Bonzini Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20250615112037.11992-4-shentey@gmail.com Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 92dc295540e..5b53f2649f1 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -305,6 +305,12 @@ fn read_data_register(&mut self, update: &mut bool) ->= u32 { } =20 fn write_data_register(&mut self, value: u32) -> bool { + if !self.control.enable_uart() { + log_mask_ln!(Log::GuestError, "PL011 data written to disabled = UART"); + } + if !self.control.enable_transmit() { + log_mask_ln!(Log::GuestError, "PL011 data written to disabled = TX UART"); + } // interrupts always checked let _ =3D self.loopback_tx(value.into()); self.int_level |=3D Interrupt::TX; --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437786; cv=none; d=zohomail.com; s=zohoarc; b=dsXRCwF/JsYiMWG6J08/7tjCvW/u52zdKAJ/2IWg1sLxD9rVxqA2VdyEHx3GrnvfS8P1Fwp/XiZ0TNOT/hQK2K/0064cNJKRTp/0foeiZ67FTG+6xALmgaafOnE4KO9dVkpaNdm7F0dzvYe95KPf5z/WSFEZMTME6oBxSjsSbMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437786; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xj0lRSY0/RSQgCPx1FZDgyFJc1m6/HOI+FjSa4wjsdw=; b=ANejE/XhLx6go6Vzi5W7+qDSYLBBO8bEMU+aAa9XKy2LOCdvS+nlkiVaJMUjTWCIhFu8amSyKoUa+pv2FDlTBuILunU6DJSp/UnVw8gp8EDkzEc8peuKjDa7W4zDskQqKE2AQHbUGdJyr57OFc1fnnqj4iY0Etx41oa056F18NU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437786294151.69024851491372; Fri, 20 Jun 2025 09:43:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoD-0006cM-UJ; Fri, 20 Jun 2025 12:41:45 -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 1uSeoA-0006be-Ka for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeo8-0000Ie-Us for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:42 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-576-Zn3nKUuSOhyJHbjsj0nEOA-1; Fri, 20 Jun 2025 12:41:38 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-acb8f9f58ebso164357866b.2 for ; Fri, 20 Jun 2025 09:41:38 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae0540815c2sm190252966b.94.2025.06.20.09.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xj0lRSY0/RSQgCPx1FZDgyFJc1m6/HOI+FjSa4wjsdw=; b=EUf476X+9/HSAhDXqh22lI3bV/jUFRHHeh/JT5g0rKYY6DT2Tm22gkqiIrOMO88fgbFZ37 DWf0G/HBl2BasqLFC3+uNZ3Dl46ULwsB3MwK4aHOyhzkBXRaRYnuWLAVvkBgM6aKsqWC+i 0ZcdTHhH5osv+MJg+mNVVvCDKHAQqVo= X-MC-Unique: Zn3nKUuSOhyJHbjsj0nEOA-1 X-Mimecast-MFC-AGG-ID: Zn3nKUuSOhyJHbjsj0nEOA_1750437697 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437697; x=1751042497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xj0lRSY0/RSQgCPx1FZDgyFJc1m6/HOI+FjSa4wjsdw=; b=UAQ/fX8oByvNoTSASy2yowXMq0o8NbonOmoLFNu/x0ieQingKrtO8Y3rUyZh2xQV3l Cq4GFW7jFIj1H4+upTOUo6y+vRXVvkGMZyudoGp9K2UclZSvIAAxZ6Nj/dsgMkNlFohE 9L0zpWKr/xG6EAgOlTgOzQJzKSx3b/h+wql1evjvioMHW3UyNM/aJp0Eg3aTahN16Ylv fYYB9h0GZWBKJ9kRaDUWSlI6xpVTeKkoVSQ2eulpJBWf5pJFDC5a69uMoDYyR1oQSHKX DZHSv0qW0i6BN9dmTxCKn++qoLOSqPubgpa8ovdFKepwNDG6AkmBLVlEs3IA20VzCcvo mJUA== X-Gm-Message-State: AOJu0Yz9ZnFIKkDdFHfjuvUNhTi4URTVbMvoTgzTUfN2W00ZjlBmI6oN mqSGefe1dQdz0rUEuD2+/gEwPTUZ/H2E1f8feSt7L7HmbObSbUd8MThDhuNW8EaIe9XVmqs/8qo fPL8NTHTAopf/Mb8IzJVMCxIJYzvcRoEbLkTW4AtQHFJJGHuZDRHM4SyqsmdQ0prdTwVCwPlr2/ GWLgqIRUnG21qaKKUM+q9wJDZSwJkGTFyRYKfPqf6c X-Gm-Gg: ASbGncsSlFihy1+1X+vaIDO4ICPkGwjaQe7+nVPhFxizgB336CY0OrbCyPalgoeEpfU KewbQSfcLh2i0iO/lHmvbS7SUGzfbV4N+P9BgyQbg8+a45dERpLTwNMqaqBnwq33Zp5kZ+yRoBL Hbhwb7jJDId5780LxmILsMgbB2Dix76rsnMVHyhc+JSWNaXTj7r9dFixAVAcoqRQNbVf83/25aJ 4eJX23DReVjD8rX2e5NVGnNKKXUTp8Ls59jDlyV6BpOZm+53Hvt0bgy0WYAuxRIjl/f1Hn8LUra 0sM/VCoPuva1Lxckq4HP4VbCOw== X-Received: by 2002:a17:907:3d51:b0:ae0:628a:5093 with SMTP id a640c23a62f3a-ae0628a61ccmr223496366b.3.1750437696652; Fri, 20 Jun 2025 09:41:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUh7cEAihUDK1wggEwKVGhZcOd3ATAZGEk/YBcmxMqJ/WV3Ot32X0qcj05SxIHXKLGolhnNw== X-Received: by 2002:a17:907:3d51:b0:ae0:628a:5093 with SMTP id a640c23a62f3a-ae0628a61ccmr223493966b.3.1750437696218; Fri, 20 Jun 2025 09:41:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu , Stefan Hajnoczi Subject: [PULL 15/24] rust: hpet: fix new warning Date: Fri, 20 Jun 2025 18:40:43 +0200 Message-ID: <20250620164053.579416-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437787797116600 Content-Type: text/plain; charset="utf-8" Nightly rustc complains that HPETAddrDecode has a lifetime but it is not clearly noted that it comes from &self. Apply the compiler's suggestion to shut it up. Reviewed-by: Zhao Liu Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- rust/hw/timer/hpet/src/device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/devi= ce.rs index a281927781e..acf7251029e 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -771,7 +771,7 @@ fn reset_hold(&self, _type: ResetType) { self.rtc_irq_level.set(0); } =20 - fn decode(&self, mut addr: hwaddr, size: u32) -> HPETAddrDecode { + fn decode(&self, mut addr: hwaddr, size: u32) -> HPETAddrDecode<'_> { let shift =3D ((addr & 4) * 8) as u32; let len =3D std::cmp::min(size * 8, 64 - shift); =20 --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437802; cv=none; d=zohomail.com; s=zohoarc; b=WY1RE2K6KiM2+U5dzyMthA4PDT4rcG8eKcyypK7lK80SDDXYvw3O1LpF/5skzTpeznT517KIi2m72we0oxL1uU+VniEQgbMKICFG5cg7R6mS8o5p/F9IM9DSgvZCyVzrqutXAgbv53DGv+G1DT9k4BpzmWjA9SqYYnp8XyzAYfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437802; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bJbNjmMjp67OqR9BVIK8ZHYJ0eu+dJxsQY3QIusygAE=; b=ku3mv+RW3d/E43dsUt6JiphNrSNFEq6MZTclBfEc8uicu9hN4noG+hwDA7tBas9uwzQ8odsP6pQOUwx7oLSdG6wH97ZdynGKEk80dowsfznU58LWQJFNqK0iQ+gVt0+nRmOJpKAvQZZY+0Mepsp1CbBG7TiMWV/eMAaXSS4U83A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437802147233.8904521124731; Fri, 20 Jun 2025 09:43:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoI-0006dZ-1R; Fri, 20 Jun 2025 12:41:50 -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 1uSeoE-0006ch-GZ for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoC-0000J4-93 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:45 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-cUn8Fq-NMs-O552K4jJ_QA-1; Fri, 20 Jun 2025 12:41:41 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-ad8a2dc92ddso133642966b.1 for ; Fri, 20 Jun 2025 09:41:41 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053e8218bsm186423966b.4.2025.06.20.09.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bJbNjmMjp67OqR9BVIK8ZHYJ0eu+dJxsQY3QIusygAE=; b=h1WhJ+QYVI2jQpPC4DIOy1kNefAxLV1OTFJAWEmeiTFHdT/34FUb3DuLQTZxQ/4pIVZ8/Q fwIQImVuiZhI/Q/xa8ZtQPREstKBtQrH58Y/SiEZt11vKolEetTES9p3BjaupIU1d2Mxtq h+UN+iV/OAQSAQRkKAt4uaJLqDvDAwU= X-MC-Unique: cUn8Fq-NMs-O552K4jJ_QA-1 X-Mimecast-MFC-AGG-ID: cUn8Fq-NMs-O552K4jJ_QA_1750437700 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437699; x=1751042499; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bJbNjmMjp67OqR9BVIK8ZHYJ0eu+dJxsQY3QIusygAE=; b=oShaDagaFzJs6qVrtg5fAQxfK1ycDbOHAcZG3NlcqIHbphTa9+rMnEnC4hSpx2osDP NksOwH7vqs3hc4AykeXb6OqeZxM+rNVIVhj/nNgOpoT4tVRFG3mJuD9VKc+v0INQ7Zdg Ck3GN2M6AswXlV790R3I5XukwaztFa+y1I4povdTEDPHOqClfrqaR6gZ/ceVXkwpwVkS inGpoOHUfU2ImRxxwctU9cka8j6b/tVDzO2nETtHgDrz0uGvKy5S68EI0UmSMblO6zIM DI8dgBPCzapmXqD7Ejrp2xMBQyAE7N1G7wJQ9pZnvhdhIxLotaPVOSce9Btpl0F4zx1j 8pLA== X-Gm-Message-State: AOJu0Yy6ij8WH8lEVpYVN+3zzF73uDCl25xZXNGHu3Vy7PMBaJJAL5Ej 0KYK8TA2PAgE0FZeFHj4MoAtw4b34D4c/JKjnON9PRKDloQ5wvWvTeJy2ERFKGG6ytfuVDDaJPp yvjjHlQ8W4USU7xcpEJ1qK3L7ORaIb8W/wYCal7dXEp2sraqGBNynlBbb566qxqcl+UesgILvvh yBDIIxTZwv/E2oXqAGlHoiXVSZmjODM6C4XT/cGD0A X-Gm-Gg: ASbGncvGzhPDGqJ8QdE7+hGEJcUSd5DI4Ggc3Nuz7cP8w4NsMI3mildQlfpNKj7HBys EF0xOb9bQZbPznfcj0zv20bArpn4l8/jJSlA/GQulGk8zLJNe79N3MG6YpmimdQ7gH7uqv9dzkJ 8YRAP8gzgGERAWbHsVhUg0vVA5CnK1kjT9tj7lAmBShRLHwwInC6UQ2bNyIFyijMyh/YjioOmtK N7NaVSPzuYDixNgSzbUc3TsLdDgifLnL9ZMaRwIAhV/07d2qFzBDaVFrWA27kSZU6VJ2f9Gk+pU aFC+1fMIdeGoQPVuTT71M7lyDg== X-Received: by 2002:a17:907:868d:b0:ad8:9d9b:40f9 with SMTP id a640c23a62f3a-ae057f20a41mr348902266b.43.1750437699315; Fri, 20 Jun 2025 09:41:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaAWa45w8ofbc5wM39cegXCSvwa0EpUzq7BQe5qB3kwBQARZzEaKzOfUrgpX3L13wKMOrb0A== X-Received: by 2002:a17:907:868d:b0:ad8:9d9b:40f9 with SMTP id a640c23a62f3a-ae057f20a41mr348899766b.43.1750437698889; Fri, 20 Jun 2025 09:41:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , Zhao Liu Subject: [PULL 16/24] i386/cpu: Move adjustment of CPUID_EXT_PDCM before feature_dependencies[] check Date: Fri, 20 Jun 2025 18:40:44 +0200 Message-ID: <20250620164053.579416-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437804151116600 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li There is one entry relates to CPUID_EXT_PDCM in feature_dependencies[]. So it needs to get correct value of CPUID_EXT_PDCM before using feature_dependencies[] to apply dependencies. Besides, it also ensures CPUID_EXT_PDCM value is tracked in env->features[FEAT_1_ECX]. Signed-off-by: Xiaoyao Li Reviewed-by: Zhao Liu Link: https://lore.kernel.org/r/20250304052450.465445-2-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 40aefb38f6d..29bce67c3a1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7349,9 +7349,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, if (threads_per_pkg > 1) { *ebx |=3D threads_per_pkg << 16; } - if (!cpu->enable_pmu) { - *ecx &=3D ~CPUID_EXT_PDCM; - } break; case 2: /* cache info: needed for Pentium Pro compatibility */ @@ -8341,6 +8338,10 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) } } =20 + if (!cpu->enable_pmu) { + env->features[FEAT_1_ECX] &=3D ~CPUID_EXT_PDCM; + } + for (i =3D 0; i < ARRAY_SIZE(feature_dependencies); i++) { FeatureDep *d =3D &feature_dependencies[i]; if (!(env->features[d->from.index] & d->from.mask)) { --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437798; cv=none; d=zohomail.com; s=zohoarc; b=GkDqCHuLHpuhJO+wKfNTbEWtxU2SrQG6U+shWXm8OwPtUjqQ+JqTEqExbB5j3TwZdZS+6dHPjNB5EHkC7JXNPYlNcqgIQ8HkZrR9udcIy8BZ9bmaipvuJENeqwpqzEJlbtP8Wow913jBsW8hV9pLoj7werZdGiBPCmTjwI4S74k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437798; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZZx4yG+bgFU4rtof6aU8LdU/H0Zr1YZu+nqmlHjr8Lw=; b=Ivgwu1XYDmJPpsDyp5xSlBSz7yY0bWYb2k2ZQ+j+YkRWIaDi7zwPJNfdQDqcg2GSMKmyR1WK542x1k59M1SEHfpcJH8WxIblmB5ulLP9oRUL6/gpNFMufUUMFzU2C4XKufJZ84Pwu0oKwiWI1nlz7ZVfAoCb6UZwSqBO8blmzqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437798491478.56802699464583; Fri, 20 Jun 2025 09:43:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoI-0006dc-GW; Fri, 20 Jun 2025 12:41:50 -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 1uSeoG-0006dA-5n for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoE-0000JI-K4 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:47 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-2rrVtwjHPdCnqRqTUJ10Cw-1; Fri, 20 Jun 2025 12:41:44 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-ae066127959so30851966b.2 for ; Fri, 20 Jun 2025 09:41:44 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae054083bb4sm186360466b.107.2025.06.20.09.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZZx4yG+bgFU4rtof6aU8LdU/H0Zr1YZu+nqmlHjr8Lw=; b=jOuL92yMPGlFBf1mpVZFPOi/rbFlfCeVYpZHuCQJDXPy5jDdMRNFtfqyrx4yfDBjNpIT1d NZalqaCOCV7VaOPYe57iUGM1oWYbHMYdgZplPvUfQI3uJeeD4uBQQaiAJnJDBOhbWDCBeg ibgoWFsRR2dGkCu+spE+4VxFLjs4ufk= X-MC-Unique: 2rrVtwjHPdCnqRqTUJ10Cw-1 X-Mimecast-MFC-AGG-ID: 2rrVtwjHPdCnqRqTUJ10Cw_1750437703 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437702; x=1751042502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZZx4yG+bgFU4rtof6aU8LdU/H0Zr1YZu+nqmlHjr8Lw=; b=MO+hDbDLMsxqP1p8iR6nirIfaUWe4/EbpBpUPbdiTxZST0iGQ+LqnXRc71soVs7R3X WA8rERWvJlSQuZwx2zr74mPjiGreijtpVJLlyBTkHKFR/yL/6dw7bDR5JA5g9rD3xnfU mDPXLKS/PhgrwCfEAAVYdEUoGuzjJUx1sWi2yO9dBdWU7s94gIkk+lblW0O9E/JAO9XZ 3nioj3+T1JL0RyTrnpNtZr+Uux+Xpt6tYFGwFkklFtqYXUBbN1pDtbYdWxdpKa34RUCT kUz8Ys5zDBDv3grWo7CNXyLwEP8MamT5nAjsQbly67C6hqjpu6p6itkPPbqH8XKSznUo rsJQ== X-Gm-Message-State: AOJu0YxUnOzeoSbh7Y6l5+kWJ90/YhtpNx3ZKx4evB63H3D5mfJ33BEm CQP4WEZdXDbBcfpwH7OdGStpp+5TOuQ+xXGBoHGYFERrmZcMcjVmn7avhBOVzlvykpFfDm+lQAm s1hGKdLLVtm3n/G5+C9ZST2uWgpLMroaBVX2HCN2+g9bpgEzxMZDCK4g+MugZX8AakrtafWfRW3 bYh4ipUJ2h7X1Edw5AwAH2Rbhjk6kS7V2KY5SB4QuW X-Gm-Gg: ASbGncuxhLFsTmlqqpDAffBR1UDUIY3sm4gEp1nW2Iqb/QfeiZFxwijYJ98f7HQHZZa v3ij/cn5t68+VSLH8/T8nk2eAm2a2C8b45eNCmRHazit3Dz5BuZFxGWSuVcr6N4GXO3GsX/v8/m HEXcKB1YDmJV9Rm0FJvD1Gc1YQmSOXaUbE8KS2yZqtQnqpHXaHeAmD5FVofXoHSKYxpYOW7K4mQ Kp2caj0w1pUDzJusyleueB6xmyFfiM24CJDMP2emR1TbUPkdYH5UXBSsqBrO31EPux7jLHA2NE/ LFUevdsrU3xLozNNBaaRnxBGnQ== X-Received: by 2002:a17:907:6088:b0:ade:399c:7a9 with SMTP id a640c23a62f3a-ae057b9257cmr343559966b.37.1750437702456; Fri, 20 Jun 2025 09:41:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8+OBMPOBFVCBBwUMWd9zIIlTFFoDLwZwTaAAO1YsR6OGyHRodWtZRBIyDDwqFZaa1pxE2OQ== X-Received: by 2002:a17:907:6088:b0:ade:399c:7a9 with SMTP id a640c23a62f3a-ae057b9257cmr343557666b.37.1750437702017; Fri, 20 Jun 2025 09:41:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , Zhao Liu Subject: [PULL 17/24] i386/cpu: Warn about why CPUID_EXT_PDCM is not available Date: Fri, 20 Jun 2025 18:40:45 +0200 Message-ID: <20250620164053.579416-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437799966116600 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li When user requests PDCM explicitly via "+pdcm" without PMU enabled, emit a warning to inform the user. Signed-off-by: Xiaoyao Li Reviewed-by: Zhao Liu Link: https://lore.kernel.org/r/20250304052450.465445-3-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 29bce67c3a1..0d35e95430f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -8339,6 +8339,9 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **err= p) } =20 if (!cpu->enable_pmu) { + mark_unavailable_features(cpu, FEAT_1_ECX, + env->user_features[FEAT_1_ECX] & CPUID_E= XT_PDCM, + "This feature is not available due to PM= U being disabled"); env->features[FEAT_1_ECX] &=3D ~CPUID_EXT_PDCM; } =20 --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437777; cv=none; d=zohomail.com; s=zohoarc; b=aROaqDLnsBtqCnRefJqb3vCzAAKPMNfbYBUM3uUYlWOseiEZVxCaKoYcoXKEjMwYjAmC7J5hb8XFU/wyH5986gYXqFUCtDki6U/0cbb64ozzmg8JnXEPql7lMM92R/InL0QIzebrNXKmv4p7iBCU5/YiST9TmDZWdmatOwhpPYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437777; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2sGYtFnI+UJzF2rX6EpStjzkEq0FKTxfvAu4tsZnx1Y=; b=I1nlYL7zyVbMB+IOo5oxO5O2zWc/UtGgbP5TyPR22nGWLpHp0U/3hfSPPXDGu2QpNRvIn+wlMMrwrAHVtuKBhWzEeCw2CFOIOtyr6005n7M5xossCxo1gPmrOX4fDJ+lp4YUU2B70iKEVImoa3yWnQD3PRC8f2daec+pRyK+rFo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437777341518.4824277366515; Fri, 20 Jun 2025 09:42:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoM-0006eT-Uz; Fri, 20 Jun 2025 12:41:54 -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 1uSeoJ-0006dr-En for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoH-0000Jw-Ui for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:51 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-7eGptlFuNii79jGXiuEIig-1; Fri, 20 Jun 2025 12:41:46 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-ae066127959so30854466b.2 for ; Fri, 20 Jun 2025 09:41:46 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053ecbe9esm184555266b.44.2025.06.20.09.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2sGYtFnI+UJzF2rX6EpStjzkEq0FKTxfvAu4tsZnx1Y=; b=ZSJnLVBiEwmM1hYZqgZjmcTu6FMeFQ9ksjTBcEEc2R0bl+X1F5nrdvb0W/y/Sft6F5rgEI 0trpDwqQoX7P53rhc/2Tsh8qOXZ44UCxGE+nkJCuF39/gmvTSFDjEegXKOv1GxXGHAOZgH GyuyeRBAN7H/gMZcAJ08wqMLrMBZrqs= X-MC-Unique: 7eGptlFuNii79jGXiuEIig-1 X-Mimecast-MFC-AGG-ID: 7eGptlFuNii79jGXiuEIig_1750437706 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437705; x=1751042505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2sGYtFnI+UJzF2rX6EpStjzkEq0FKTxfvAu4tsZnx1Y=; b=jMsTHtbWehxuRi7legc/NTOY0Jml1+qfn7meNxpz661RQ7/zDOOvJj1CWm9752ULSU GrCc7wynxP/KAFMvj+JyHXEqaaS42Vz80v+YY1z8b9YMRtI9JRdi7ODODlomITpDAxqo ttGQpVGqHosmQlEi1NGOzjjvBtRa69c8L095qZwpTvosD1Uwb5/vQpsuiboupDTk5Ncg MjRvkzerT8ALddij3cqBK/NQK32amzrIpuoKAFoRGrfH+QKCgulmNlO08y+VTPhYzEOg PpUemFHF3r3tVWxsuZTjrMC5bgiGLy89igTn0x6s8MR880NW/RVh5n6Yt1RpmaGbRuCE QG5w== X-Gm-Message-State: AOJu0Yx2SYzJqeDZVSxLBzGQql7iJZYlXQMT86iTc9+e8DIpq0IgWAsS 35lOh+tPqA1YwwjqSzAPY2NX92JVpoBk6bhPrt3nsR42e3cJLRE980g0hS7g3GCx/SgVWjhofv4 9dVVwEFlGpR1jrjSqU3WFS5ZM9y4+KCnnsPsURNIfsOcep8wyETokwp98f2js8ENHNqNgkW9bE4 O1cO0RZ8hOquEGqo6BDWmtPEoRnYJ6Bo+08H/P2YDC X-Gm-Gg: ASbGncu1VT8HFkSVgPXpjlDqTiO2xR1al8JXee+bTgLegjN4oigQEiMjzX/3rsJO1Z8 xvtPFva7OWwXXe/msD6MXHU+RIJIRZQ3lnndduGc1Q3cQXWZj1V4ZRLERKeqGtH+Wm1V2xHo7Ia TyDMzrgm6gvyCFt8eOqGQ8HRtTLm8nyDbov00+xlHQusWyytdp8Bqt3usVmWlJbJNkLBb+/KpIO t2E3hZkln0f1mkB4ZLb+P7o71q2d9TNMSK0OnNd83/+4tdd3VJMqztuM36ANGn7c8Mmy1jsqZsa YC40/7XFdkPUROzKfuJzwA9MAQ== X-Received: by 2002:a17:907:3f29:b0:ae0:54b7:f180 with SMTP id a640c23a62f3a-ae057baf2c3mr281740066b.42.1750437705029; Fri, 20 Jun 2025 09:41:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETsHycDkaEDSnsNqaOPNEigIN/u35z+4nFC1syE49IfRV3zqhZ6G0qMgBXC4bKAqfqiLg0yg== X-Received: by 2002:a17:907:3f29:b0:ae0:54b7:f180 with SMTP id a640c23a62f3a-ae057baf2c3mr281737866b.42.1750437704599; Fri, 20 Jun 2025 09:41:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li Subject: [PULL 18/24] i386/tdx: Error and exit when named cpu model is requested Date: Fri, 20 Jun 2025 18:40:46 +0200 Message-ID: <20250620164053.579416-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437777801116600 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li Currently, it gets below error when requesting any named cpu model with "-cpu" to boot a TDX VM: qemu-system-x86_64: KVM_TDX_INIT_VM failed: Invalid argument It misleads people to think it's the bug of KVM or QEMU. It is just that current QEMU doesn't support named cpu model for TDX. To support named cpu models for TDX guest, there are opens to be finalized and needs a mount of additional work. For now, explicitly check the case when named cpu model is requested. Error report a hint and exit. Signed-off-by: Xiaoyao Li Link: https://lore.kernel.org/r/20250612133801.2238342-1-xiaoyao.li@intel.c= om Signed-off-by: Paolo Bonzini --- target/i386/kvm/tdx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 820ca3614e2..2b52de9d71b 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -739,8 +739,14 @@ static int tdx_kvm_type(X86ConfidentialGuest *cg) =20 static void tdx_cpu_instance_init(X86ConfidentialGuest *cg, CPUState *cpu) { + X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); X86CPU *x86cpu =3D X86_CPU(cpu); =20 + if (xcc->model) { + error_report("Named cpu model is not supported for TDX yet!"); + exit(1); + } + object_property_set_bool(OBJECT(cpu), "pmu", false, &error_abort); =20 /* invtsc is fixed1 for TD guest */ --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437798; cv=none; d=zohomail.com; s=zohoarc; b=Rda866TSJ6GMfNcNnpM1sVYdjiIG4oSFvh6SQLyMS0j6liSliu7Fc2sVsQdfLzUgSFmOjnkg7iOgaNtnKnK8WL2URn6bdwXgDPYcnONbJS1BQkIjyE4iVoEGD5Y05A4Dx/KWheJeaagqvIJy9M176rFe811ZmVpeioyMHVRM8Po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437798; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AC4zT8sWe4ssqB8c1y68D3S1OxvabGsR5nhiZP73ISE=; b=dsKo06S6GM4JwqEeB1L/Xm2PHaJzV5ue6ndf76g3FSNAwtuf5F2swodrRdX2GNtdpaAR+shtU2D0DrfS8JT87rpftpukEfdAwubR2Rhoj0FU7C/EGLBCL/HmqNc222U/yKUZSPyKngw52RM3fT1f0ughP1oyiXvA9sQ+OMOGOjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437798281839.4776598138385; Fri, 20 Jun 2025 09:43:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoO-0006jZ-1t; Fri, 20 Jun 2025 12:41:56 -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 1uSeoL-0006eI-RG for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoK-0000KY-9W for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:53 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-D2R1i0VeO_K8s1D7e4btcA-1; Fri, 20 Jun 2025 12:41:49 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-ad89a3bcc62so152242566b.0 for ; Fri, 20 Jun 2025 09:41:49 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae0543421e9sm185450166b.185.2025.06.20.09.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AC4zT8sWe4ssqB8c1y68D3S1OxvabGsR5nhiZP73ISE=; b=iSxheyQEXQxQm1pv42wtMHdtFtKMfyh3e+9+VFg5wRqSUQchcy7Rq8Dgr8qr4XIEDyH2Xv lmkr4C4uhTlPj5QZyPuBnf4henaBmrmaLwnJSrgtFW7Z+iCNEdFhbUUeWOQTQAb1EObM63 /LJyIz2q1dxDLJs4XCjrQwWOBaHOGSE= X-MC-Unique: D2R1i0VeO_K8s1D7e4btcA-1 X-Mimecast-MFC-AGG-ID: D2R1i0VeO_K8s1D7e4btcA_1750437708 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437708; x=1751042508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AC4zT8sWe4ssqB8c1y68D3S1OxvabGsR5nhiZP73ISE=; b=NXJFP2irmq3KOHpcSgZypseH55UCVol8rvTLDKAoi4DF8/FBvC7LSV24iWT3//LCUo 6VKscOLpQbheDk8oHUfl3Vn3qXKTSieegOEaMochCZCHDZ8TCG5JpLdlQONvtWPV/yol h0Geh3L7Aw8Khi0A8d5YOVoEfElmXSCt4Yb+ematEQjSWgc2/8wDFUILyze3UAxfzrR7 JNSPFipCfyQbX6rLH5ZLVSC8HxdJCpKCRYelIgPSxLwA1+nJ5Yrlsi4g9hgo8/aM4RoZ osBEBWuchg2WhcbRvONhD3bu+TMcgztOphlqzX6cGY7WFDEFRNpfY5tPuzkCHUP51RdE qhng== X-Gm-Message-State: AOJu0Yy/YV0KcIVgIqGtEIcN3G3SheZwnOeTxVkl45ZcKa1AR/eD0rhb 4Ok6F7N8jFRa4E8WaIBhHmjK41Ouzu9O4bIl9SUGNXXsQ94oMlw7dq5+o6/ha0Vc55vpRtGoyCm P1YO8BpF0Pd0xQ85n7rkHiIDQVjDfS02waPPZPH7iCQP4Ft3v1RD9mYfir93uAIE0xjEd6ThqFr qkQPaAGnjmZUAT3kjRB8W4y3uR6suLb8Bfzm4Q2C5g X-Gm-Gg: ASbGncskzjUJpxsN0PpDMxB5fvoCm5MLzys6CbB+U249WTywJOYa2ix6CL3Hcz/R7H0 HFVvIxMLooRp6Co0MvW6oSmvLySU8LqkN0pY507iUxDtIZtiXiKjXmXb8tTssBVYoT1tlsxBF2P RlMeFTHOqvqFVlbeoF3bsd99OjQ/yqxiTY6B+NQOEXTdCcSEl4KN0XWVDUcBS0CxkA2ARKfvkl5 dcxfPKG1A9QfZ6b3aDWWIRennx50xDT39GeRQDYJtK+NgBk3tOFDnYtTyaQnKCsUTeo6zhiCBN7 9vcqFLbJhS+fTZwZTtqAiHWF9g== X-Received: by 2002:a17:907:3c8b:b0:ae0:180b:bb54 with SMTP id a640c23a62f3a-ae057a32920mr341122266b.26.1750437707809; Fri, 20 Jun 2025 09:41:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwHct18rcZGnXx72ZNqidNLlwvFJJpJCCiioBIMlRmeFQjhnl2fUOW7GxEvUH3THIj+/w51w== X-Received: by 2002:a17:907:3c8b:b0:ae0:180b:bb54 with SMTP id a640c23a62f3a-ae057a32920mr341120066b.26.1750437707278; Fri, 20 Jun 2025 09:41:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , Igor Mammedov , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 19/24] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f Date: Fri, 20 Jun 2025 18:40:47 +0200 Message-ID: <20250620164053.579416-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437800013116600 From: Xiaoyao Li The name of "enable_cpuid_0x1f" isn't right to its behavior because the leaf 0x1f can be enabled even when "enable_cpuid_0x1f" is false. Rename it to "force_cpuid_0x1f" to better reflect its behavior. Suggested-by: Igor Mammedov Signed-off-by: Xiaoyao Li Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Igor Mammedov Link: https://lore.kernel.org/r/20250603050305.1704586-2-xiaoyao.li@intel.c= om Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 4 ++-- target/i386/kvm/tdx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5910dcf74d4..51e10139dfd 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2269,7 +2269,7 @@ struct ArchCPU { bool enable_cpuid_0xb; =20 /* Force to enable cpuid 0x1f */ - bool enable_cpuid_0x1f; + bool force_cpuid_0x1f; =20 /* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level; @@ -2539,7 +2539,7 @@ void mark_forced_on_features(X86CPU *cpu, FeatureWord= w, uint64_t mask, =20 static inline bool x86_has_cpuid_0x1f(X86CPU *cpu) { - return cpu->enable_cpuid_0x1f || + return cpu->force_cpuid_0x1f || x86_has_extended_topo(cpu->env.avail_cpu_topo); } =20 diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 2b52de9d71b..acbe7497543 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -752,7 +752,7 @@ static void tdx_cpu_instance_init(X86ConfidentialGuest = *cg, CPUState *cpu) /* invtsc is fixed1 for TD guest */ object_property_set_bool(OBJECT(cpu), "invtsc", true, &error_abort); =20 - x86cpu->enable_cpuid_0x1f =3D true; + x86cpu->force_cpuid_0x1f =3D true; } =20 static uint32_t tdx_adjust_cpuid_features(X86ConfidentialGuest *cg, --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437856; cv=none; d=zohomail.com; s=zohoarc; b=WYVjID8bvg4yBEzjGRyO3WrRmEQQI/M5M06inruxLL/gsW2afd8UGjwNmWbWvukF6DXxXguXJckD5VZHydm9VliJ9iLHBlAB+09aXNE5qHxceVFfGJhBtZSfRScak4NHS6zZHLqyTDQNWyy7ocnMmAhnnWkOgOWFKZ80ggUgBsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437856; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yl1rFXyPtvsbXYd9SVXPVaJzOj3OjnrKUbUoWlyChdo=; b=aYBiT4wDxLtalkT8dIYUYuTkiH/tlmFZFHQXN5CeECTqjArXrkPSd7VWnIbYc2uZNqZUH+UsMUog2a2HsCOBk19ultB/lNiIJ7ervPGKN9qxkcqppjw9qzidafs2WRht0ti90LLC+vvY+I7AVn1EWkJ+zMsvQCJkzNPabD7lIvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437856153725.1793633357734; Fri, 20 Jun 2025 09:44:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeoP-0006oi-Tb; Fri, 20 Jun 2025 12:41:57 -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 1uSeoO-0006lE-4Y for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoM-0000L4-L9 for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:41:55 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-o8kDJDm4PjmjA0MWnuQc2w-1; Fri, 20 Jun 2025 12:41:52 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-60724177a1fso2028539a12.3 for ; Fri, 20 Jun 2025 09:41:52 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a1857e8f9sm1641292a12.32.2025.06.20.09.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yl1rFXyPtvsbXYd9SVXPVaJzOj3OjnrKUbUoWlyChdo=; b=DBxFIuKIk0f7sL0WPAYpntPORfs4Q5kSuTSHnMSYOrgA2FPwq/Tlt/F2jYdleA03luJCR9 w0npHDDmRrsqOfPBNeYqGgTsHnNuSwJ7IU7WarpXqrYan1fapjsu9Yb8106CkAlTxRRoWJ iHAlNOO7CJabn8zkpJkbO3mvhWpJkLk= X-MC-Unique: o8kDJDm4PjmjA0MWnuQc2w-1 X-Mimecast-MFC-AGG-ID: o8kDJDm4PjmjA0MWnuQc2w_1750437712 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437711; x=1751042511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yl1rFXyPtvsbXYd9SVXPVaJzOj3OjnrKUbUoWlyChdo=; b=EphWi1Xx9WTQUAAITRFCK/QdqXKAGKE5F48Ox+qXk9SDmeI4lyL8UiBFahsSdI2aJP d2G0VGSlTTlXARcVrK/nhQ/EQDZeA6kjUqTDDTN5/Cxj7H3nnyaIq8qKQBP9mA6caIdX UJnx4UXOX2VLhiCKvOsLFPANpHdXCvcGwxHdnLv4rEwLTmi+hhZ08Wywc9xdDQ0vXTDi C/yVGcnVEnEox/YG9C/HTB4Zhagrz3Xx12JTeI7MZ8ZnRCrqi+8cCeGnlvPwHVWFuKyT wvUF/nTctrb4XagBbtQdbGByArDEaEuheGMaIboofIv3MO45MVtevfS6j9eVINFPOm2q QasQ== X-Gm-Message-State: AOJu0YyGEtgQHf0W084QdmP1D6ORK6GDuhyL4gANmBueZvtCbefmGOoI tB5EYj/huo9XJ0HkxV3Lu/+1LPUHh/cUFqV0KdfyS+I1DaQYDbVzGYaQI0/vK9qCOblSePlZef/ q+iWC4BAf38XV6Qf7/3Pe2YUZ3Xo8jvJpDikvf/x8Ut2fRk5qc9kevOWs2lABnXzrfL2tLWm02J vmt/afOJzauUYmr/9/ud30K2F0+O0WFrg599mDx1i0 X-Gm-Gg: ASbGncvIkAL/P1hBodYQ7ETy60xvydCPa4NHIBn9oG4zeP8fhO7gPo28iGobEvog9Pg UgV+UD8yu6pW279lhpBRuELmg1Y+5SAmjnRP7petEpD3EZPd/ekPIF+ZVrE4TV+j97w/aaXytKj 48cxcB9AniSKUBv/+UFXiWUCAuacMs0ALnJ2nj5CLVyFGvAX/XsbsC6Zsq7tBjmuxnUYjBc+qzI UL/K2E0ws+5lz8Vqp004eusLa8g8BVveX3OAD0qfDW9ZgUkpcW//1/zSd96VQlxfcVKoSfZG9OJ 2pvwvOuJXMDxjVIc1jLP88rI+Q== X-Received: by 2002:a05:6402:26ca:b0:608:47ee:dc4 with SMTP id 4fb4d7f45d1cf-60a1cd31b60mr3003099a12.23.1750437710577; Fri, 20 Jun 2025 09:41:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQYOA+pZWoCsSHDbrPxRwqSYQOuWEAP/XL25oCkoRWsBmzZNi9YEneEICw1WM9dQMT5Bbd2Q== X-Received: by 2002:a05:6402:26ca:b0:608:47ee:dc4 with SMTP id 4fb4d7f45d1cf-60a1cd31b60mr3003079a12.23.1750437710111; Fri, 20 Jun 2025 09:41:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Igor Mammedov Subject: [PULL 20/24] i386/tdx: Fix the typo of the comment of struct TdxGuest Date: Fri, 20 Jun 2025 18:40:48 +0200 Message-ID: <20250620164053.579416-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437858680116600 From: Xiaoyao Li Change sha348 to sha384. Signed-off-by: Xiaoyao Li Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Igor Mammedov Link: https://lore.kernel.org/r/20250603050305.1704586-3-xiaoyao.li@intel.c= om Signed-off-by: Paolo Bonzini --- target/i386/kvm/tdx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm/tdx.h b/target/i386/kvm/tdx.h index 04b5afe199f..8dd66e90149 100644 --- a/target/i386/kvm/tdx.h +++ b/target/i386/kvm/tdx.h @@ -40,9 +40,9 @@ typedef struct TdxGuest { bool initialized; uint64_t attributes; /* TD attributes */ uint64_t xfam; - char *mrconfigid; /* base64 encoded sha348 digest */ - char *mrowner; /* base64 encoded sha348 digest */ - char *mrownerconfig; /* base64 encoded sha348 digest */ + char *mrconfigid; /* base64 encoded sha384 digest */ + char *mrowner; /* base64 encoded sha384 digest */ + char *mrownerconfig; /* base64 encoded sha384 digest */ =20 MemoryRegion *tdvf_mr; TdxFirmware tdvf; --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437794; cv=none; d=zohomail.com; s=zohoarc; b=bjvhv4BeCPm/gwZpRaFdWZayVld9XpapgCmla9rYO+QqZwumoElupzVS5UfNL8P8r/cEv5yX4g6IQAD/CoJOQOthBeRnva4RKqyldHXLEGLqfnT4dEkZtAyxsW8uyQf6gCETn8G0twgaYv2Jnp2d4Y71xNaIDR87FkCVD+jo0Os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437794; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0iz8TBbp2Wl1d26CB0v1zApr7MJNN6I1UtHkwFZ3ZYg=; b=XAEKN2oGMzlkRpu4qRFH6ZOecnSyusfHy/4odToYxrH2LEhvqXISXJzP0bEF3QC/bWLnH4NQMXQB/v03Va/tAReKR/ygtSBiHN35uEhBoiS+Pf+mp4Xwss2SXhs0zKO1BFG5IgQjk9aaxgJ3jq8U4Km447SCeTeV7FjMgTvj8c0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437794367177.03465588983067; Fri, 20 Jun 2025 09:43:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeob-0007AA-Rc; Fri, 20 Jun 2025 12:42:09 -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 1uSeoS-0006ui-9F for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoQ-0000Lr-El for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:00 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-kt2pXrtYM8itNwqXg3HGNQ-1; Fri, 20 Jun 2025 12:41:56 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-ade5013dfe7so188967066b.2 for ; Fri, 20 Jun 2025 09:41:56 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae0541b6f8asm186204566b.117.2025.06.20.09.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0iz8TBbp2Wl1d26CB0v1zApr7MJNN6I1UtHkwFZ3ZYg=; b=FEqrve+T+HpIcsj1zQDjUZh7MgXfrBTtKZZaaQs0rtpPFZu+DIb4GM6lfGKBIHvYT07QLh SzZ5B5GGbEyec0DjCc/apWbB8J83vhK53NcbTf7pJpch/Ff/UOzwVSCjLqvHMNHfsBtZzd sNf1U7Xn9mAY4WIW2et7JRrlrXyBBUU= X-MC-Unique: kt2pXrtYM8itNwqXg3HGNQ-1 X-Mimecast-MFC-AGG-ID: kt2pXrtYM8itNwqXg3HGNQ_1750437715 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437713; x=1751042513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0iz8TBbp2Wl1d26CB0v1zApr7MJNN6I1UtHkwFZ3ZYg=; b=fdxd2G7jHyYU711dnOglVmTf2l3ali2SD1hfZLFlNM7LxbShBkXo+yLLxYIlO5K3vi wt/9jlOaKJlKAT2VhnDpS3nTscGcInvsmquxsAi44L8At5wFkJWkgt7Kw0U6NQ1GVwha BORa3YP4lqa6np7k+JltFWxypu8v5tJrR5bX6RnXx3EY48cpA6C5ELj3fjxUsrRUBSg3 B1tpENblFMdEupzBNWUdw/KouUDbokPiycA415ZkqgjaQfu9EVdDGKebFt9K1T0ZI31k kW8KOrbneKPgpwIBQNKeeceUvEKBFbVcLvdvZI1f+bxk8iTsNop8I/8jWqFHDpvhEKDh 8ylQ== X-Gm-Message-State: AOJu0Yw7vUFFLZ2R3kt7WAvkTvQnOBO1JRjqUX5479bP4+NqjKTGK873 zXbB6axNWhg1rzVPeWd++bVJutN4phmu+mvtaBkrhiON6IuNEIOokm86XBgzMA3zhqBIT7MPh/q +Ez6xV0CabONzhWsKO+FQMdQvHVaeMuX5jhf5sndfmTT8n30zcE4GOPMn0y12sywpDxA4eVz37/ f81Xq4BQFchDepKhpF8OitTPZHlPE6jBukUjXThTvB X-Gm-Gg: ASbGncvFh7l81RjHVBrgE5VHUzsEFFd4VTJCxNJcG5yh+gP7A1D/msKX6QXae5ZLlhg zTaJQMKglq1V+jCzVhD9Vogtukwey5hlSL2s/a4yc7auRrOA5gXFkJGntorDvo5aUKE08vItLw4 ewY28sm6T02OoKMkcEr2C8A6rHFCBIMTs4OEFJHcCeYidvNjgACpUuUW1lFOVfhqefgiDtAI0t1 Rb6b3FlXk2e9yYQKSo59oVldN1YJT/KjJ+EfYq55Hc7rl4+bMoZn0LFxMsxHUzNqF3INhOeuo75 PTvQ6LPkUk2gMj3UW+gBR6qmWg== X-Received: by 2002:a17:907:d807:b0:ad8:adbc:bbf6 with SMTP id a640c23a62f3a-ae057c3e3c1mr346919066b.58.1750437713520; Fri, 20 Jun 2025 09:41:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1ynPxnFxxNVEuu4UWsjLDWBgwtm9FU4ZWIomywsVqP+1OA4iMzchbyZ1TgF+vpJUV3Owmzw== X-Received: by 2002:a17:907:d807:b0:ad8:adbc:bbf6 with SMTP id a640c23a62f3a-ae057c3e3c1mr346916166b.58.1750437713025; Fri, 20 Jun 2025 09:41:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Igor Mammedov Subject: [PULL 21/24] i386/tdx: Clarify the error message of mrconfigid/mrowner/mrownerconfig Date: Fri, 20 Jun 2025 18:40:49 +0200 Message-ID: <20250620164053.579416-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437795953116600 From: Xiaoyao Li The error message is misleading - we successfully decoded the data, the decoded data was simply with the wrong length. Change the error message to show it is an length check failure with both the received and expected values. Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Xiaoyao Li Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Igor Mammedov Link: https://lore.kernel.org/r/20250603050305.1704586-4-xiaoyao.li@intel.c= om Signed-off-by: Paolo Bonzini --- target/i386/kvm/tdx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index acbe7497543..2284167141a 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -1032,7 +1032,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp) return -1; } if (data_len !=3D QCRYPTO_HASH_DIGEST_LEN_SHA384) { - error_setg(errp, "TDX: failed to decode mrconfigid"); + error_setg(errp, "TDX 'mrconfigid' sha384 digest was %ld bytes= , " + "expected %d bytes", data_len, + QCRYPTO_HASH_DIGEST_LEN_SHA384); return -1; } memcpy(init_vm->mrconfigid, data, data_len); @@ -1045,7 +1047,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp) return -1; } if (data_len !=3D QCRYPTO_HASH_DIGEST_LEN_SHA384) { - error_setg(errp, "TDX: failed to decode mrowner"); + error_setg(errp, "TDX 'mrowner' sha384 digest was %ld bytes, " + "expected %d bytes", data_len, + QCRYPTO_HASH_DIGEST_LEN_SHA384); return -1; } memcpy(init_vm->mrowner, data, data_len); @@ -1058,7 +1062,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp) return -1; } if (data_len !=3D QCRYPTO_HASH_DIGEST_LEN_SHA384) { - error_setg(errp, "TDX: failed to decode mrownerconfig"); + error_setg(errp, "TDX 'mrownerconfig' sha384 digest was %ld by= tes, " + "expected %d bytes", data_len, + QCRYPTO_HASH_DIGEST_LEN_SHA384); return -1; } memcpy(init_vm->mrownerconfig, data, data_len); --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437780; cv=none; d=zohomail.com; s=zohoarc; b=CXlfHkdAJEyjgEKILkdF8B3ptQDR7W49bFPbLdnohIfX/n6OlP+XXBDAbdemcsW2esD6s0FzzhqvbKSS5XJNolpOjSmXduL/ALXkq3gQy84Rq80gpNaY+RXPZqQlkEgWLY5Op0ywLgWn28TJxtt1Wo+kkExJ7t/YbBp00Uewzic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437780; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=c0psjyOIJ8t+sVmPA16Jc6dLmv441phUHEvX7zxJTbc=; b=PM3fLWOWateyl0ZiLF+OJtJlBKsdl7WZ6nc2ldFg4NckvnY9lMh9cpPZJFmQiPz0UyPHm8Fg8XYN4yOdsZ6Zm3u5oYkbTweraHY6FJdoasWNT27ycFeYT9Iek1j6OyekUIvVIC7HY29uPwB9WjZT7XaTkTKHG2pW+KNhzmJP8jY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437779927764.2809679961928; Fri, 20 Jun 2025 09:42:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeon-0007Mw-2T; Fri, 20 Jun 2025 12:42:21 -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 1uSeoZ-0007AC-1r for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoW-0000Mk-5t for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:06 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-4HdD0ak6PumdRtSksUX6gQ-1; Fri, 20 Jun 2025 12:42:01 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-ad8adc22e88so181485966b.0 for ; Fri, 20 Jun 2025 09:42:01 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a18514500sm1645835a12.5.2025.06.20.09.41.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c0psjyOIJ8t+sVmPA16Jc6dLmv441phUHEvX7zxJTbc=; b=VcL14ukkkzS0dwPBGF/ke3n8sUPDlgzhr487uMbdTw7ojo+trkeA906F0VvI8cMLAmLARH 6f/mkmPx+F+fz+CCOBFrXBxnf+sbxmnH3+vBrMUGM5PahbKcRUzgdU0Fun9OvQEiM1M0qj QD0+doHWRBwJLVwx/QTX8chlLRH+pSE= X-MC-Unique: 4HdD0ak6PumdRtSksUX6gQ-1 X-Mimecast-MFC-AGG-ID: 4HdD0ak6PumdRtSksUX6gQ_1750437720 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437720; x=1751042520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c0psjyOIJ8t+sVmPA16Jc6dLmv441phUHEvX7zxJTbc=; b=oSna8n/XuLYhnSIgPnDNGm9IAk+AwxS9TkNadBnHRmkDnHYuoqvaKZ7Kds149twsdH qvUKvpf8NLeiFw3lCoSM3El0H3kBusjYMx7YLqN9ZNzd5790nGNTWhNHONMd22z0Uyga ft1lHv3IQP2F0zlZcOo4vkCkqF9PUvf3rQe6UOUxB97NajK3kAJkFsxn+x5BHaWu60mH iC3NNpkW0mDDg6cj85erZqpCBhPaepmQV4c2+mQb2ybi6nAZ8hs/E1LjkZoBnM69HE4y t2K0YrLuqQFjZX5n1kcPO7skCCTuoYM2SUsqJfOY7PWj1rGfRqSi/wJ5qqk23odxNIYw 73pA== X-Gm-Message-State: AOJu0Yx8TH+61XeH+jkvLJL1yu4B0BnTsYzXkCqBMspZqiFb2ahP5irW pmKARtZOg2SDicUA7RfCa+NbS93suSTbMcpBSs5XIH3P23AeQwuYhxGbcbSVq3HRaPwqvKYpBnZ XAm1cXxaCB52U9PCbP1nwf1gmljhaqFBrjKacfweoj6R48gWZsQCyCbWJE8Lnt+kv8cJxHDqx6U l1O4NyMeV+LM3+fx6Utgu0q397dO2AWJBYacQUuHEC X-Gm-Gg: ASbGncuZia5w9NX0ps/7oQa87pCC5+fYDCudzQ0B5ekyQh1HvvCrCnHgr7ZTYSnT1G0 eJCzWi0CpqtU2U47FfBpoKgeqh4ILI6NtFAKw8T/PHpSaBWTIaNRdPX/TJNY5mdImMruopoDkyD GlcELj7i7hH8oYD34gmUaYx0lfagN0wHm4g4EXJ3+cr2IJ0ek02KjGjP6sWOkwLzHnxp6Nlf+V/ ux2r0eFyr21aIgndehqLRDjH+OYsyFJVpFQQleXcv68SEx3+lWzEY+vaiLdwpOj5OF+zMLdMwPQ 45DPUb3TuCzrFnvjuvFTCxtdMw== X-Received: by 2002:a05:6402:44cb:b0:60b:8603:2ff8 with SMTP id 4fb4d7f45d1cf-60b86033002mr763872a12.15.1750437719439; Fri, 20 Jun 2025 09:41:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCHS+XzSJbsKxocy3WSrsazNWtt7VSoFdleBXPs6wfZF1smodP5MLXI7TB+55z3W4XKZD7vw== X-Received: by 2002:a05:6402:44cb:b0:60b:8603:2ff8 with SMTP id 4fb4d7f45d1cf-60b86033002mr763848a12.15.1750437718772; Fri, 20 Jun 2025 09:41:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 22/24] update Linux headers to v6.16-rc3 Date: Fri, 20 Jun 2025 18:40:50 +0200 Message-ID: <20250620164053.579416-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437784255116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- include/standard-headers/asm-x86/setup_data.h | 13 +- include/standard-headers/drm/drm_fourcc.h | 45 +++++++ include/standard-headers/linux/ethtool.h | 124 +++++++++--------- include/standard-headers/linux/fuse.h | 6 +- .../linux/input-event-codes.h | 3 +- include/standard-headers/linux/pci_regs.h | 12 +- include/standard-headers/linux/virtio_gpu.h | 3 +- include/standard-headers/linux/virtio_pci.h | 1 + linux-headers/asm-arm64/kvm.h | 9 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/linux/bits.h | 4 +- linux-headers/linux/kvm.h | 25 ++++ linux-headers/linux/vhost.h | 4 +- 13 files changed, 177 insertions(+), 73 deletions(-) diff --git a/include/standard-headers/asm-x86/setup_data.h b/include/standa= rd-headers/asm-x86/setup_data.h index a483d72f428..2e446c1d858 100644 --- a/include/standard-headers/asm-x86/setup_data.h +++ b/include/standard-headers/asm-x86/setup_data.h @@ -13,7 +13,8 @@ #define SETUP_CC_BLOB 7 #define SETUP_IMA 8 #define SETUP_RNG_SEED 9 -#define SETUP_ENUM_MAX SETUP_RNG_SEED +#define SETUP_KEXEC_KHO 10 +#define SETUP_ENUM_MAX SETUP_KEXEC_KHO =20 #define SETUP_INDIRECT (1<<31) #define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT) @@ -78,6 +79,16 @@ struct ima_setup_data { uint64_t size; } QEMU_PACKED; =20 +/* + * Locations of kexec handover metadata + */ +struct kho_data { + uint64_t fdt_addr; + uint64_t fdt_size; + uint64_t scratch_addr; + uint64_t scratch_size; +} QEMU_PACKED; + #endif /* __ASSEMBLER__ */ =20 #endif /* _ASM_X86_SETUP_DATA_H */ diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index a8b759dcbc8..c8309d378bf 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -421,6 +421,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a #define DRM_FORMAT_MOD_VENDOR_MTK 0x0b +#define DRM_FORMAT_MOD_VENDOR_APPLE 0x0c =20 /* add more to the end as needed */ =20 @@ -1493,6 +1494,50 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t m= odifier) /* alias for the most common tiling format */ #define DRM_FORMAT_MOD_MTK_16L_32S_TILE DRM_FORMAT_MOD_MTK(MTK_FMT_MOD_TI= LE_16L32S) =20 +/* + * Apple GPU-tiled layouts. + * + * Apple GPUs support nonlinear tilings with optional lossless compression. + * + * GPU-tiled images are divided into 16KiB tiles: + * + * Bytes per pixel Tile size + * --------------- --------- + * 1 128x128 + * 2 128x64 + * 4 64x64 + * 8 64x32 + * 16 32x32 + * + * Tiles are raster-order. Pixels within a tile are interleaved (Morton or= der). + * + * Compressed images pad the body to 128-bytes and are immediately followe= d by a + * metadata section. The metadata section rounds the image dimensions to + * powers-of-two and contains 8 bytes for each 16x16 compression subtile. + * Subtiles are interleaved (Morton order). + * + * All images are 128-byte aligned. + * + * These layouts fundamentally do not have meaningful strides. No matter h= ow we + * specify strides for these layouts, userspace unaware of Apple image lay= outs + * will be unable to use correctly the specified stride for any purpose. + * Userspace aware of the image layouts do not use strides. The most "corr= ect" + * convention would be setting the image stride to 0. Unfortunately, some + * software assumes the stride is at least (width * bytes per pixel). We + * therefore require that stride equals (width * bytes per pixel). Since t= he + * stride is arbitrary here, we pick the simplest convention. + * + * Although containing two sections, compressed image layouts are treated = in + * software as a single plane. This is modelled after AFBC, a similar + * scheme. Attempting to separate the sections to be "explicit" in DRM wou= ld + * only generate more confusion, as software does not treat the image this= way. + * + * For detailed information on the hardware image layouts, see + * https://docs.mesa3d.org/drivers/asahi.html#image-layouts + */ +#define DRM_FORMAT_MOD_APPLE_GPU_TILED fourcc_mod_code(APPLE, 1) +#define DRM_FORMAT_MOD_APPLE_GPU_TILED_COMPRESSED fourcc_mod_code(APPLE, 2) + /* * AMD modifiers * diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 5d1ad5fdeab..cef0d207a62 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -2295,71 +2295,75 @@ static inline int ethtool_validate_duplex(uint8_t d= uplex) #define RXH_XFRM_SYM_OR_XOR (1 << 1) #define RXH_XFRM_NO_CHANGE 0xff =20 -/* L2-L4 network traffic flow types */ -#define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */ -#define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */ -#define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */ -#define AH_ESP_V4_FLOW 0x04 /* hash only */ -#define TCP_V6_FLOW 0x05 /* hash or spec (tcp_ip6_spec; nfc only) */ -#define UDP_V6_FLOW 0x06 /* hash or spec (udp_ip6_spec; nfc only) */ -#define SCTP_V6_FLOW 0x07 /* hash or spec (sctp_ip6_spec; nfc only) */ -#define AH_ESP_V6_FLOW 0x08 /* hash only */ -#define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */ -#define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */ -#define AH_V6_FLOW 0x0b /* hash or spec (ah_ip6_spec; nfc only) */ -#define ESP_V6_FLOW 0x0c /* hash or spec (esp_ip6_spec; nfc only) */ -#define IPV4_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */ -#define IP_USER_FLOW IPV4_USER_FLOW -#define IPV6_USER_FLOW 0x0e /* spec only (usr_ip6_spec; nfc only) */ -#define IPV4_FLOW 0x10 /* hash only */ -#define IPV6_FLOW 0x11 /* hash only */ -#define ETHER_FLOW 0x12 /* spec only (ether_spec) */ +enum { + /* L2-L4 network traffic flow types */ + TCP_V4_FLOW =3D 0x01, /* hash or spec (tcp_ip4_spec) */ + UDP_V4_FLOW =3D 0x02, /* hash or spec (udp_ip4_spec) */ + SCTP_V4_FLOW =3D 0x03, /* hash or spec (sctp_ip4_spec) */ + AH_ESP_V4_FLOW =3D 0x04, /* hash only */ + TCP_V6_FLOW =3D 0x05, /* hash or spec (tcp_ip6_spec; nfc only) */ + UDP_V6_FLOW =3D 0x06, /* hash or spec (udp_ip6_spec; nfc only) */ + SCTP_V6_FLOW =3D 0x07, /* hash or spec (sctp_ip6_spec; nfc only) */ + AH_ESP_V6_FLOW =3D 0x08, /* hash only */ + AH_V4_FLOW =3D 0x09, /* hash or spec (ah_ip4_spec) */ + ESP_V4_FLOW =3D 0x0a, /* hash or spec (esp_ip4_spec) */ + AH_V6_FLOW =3D 0x0b, /* hash or spec (ah_ip6_spec; nfc only) */ + ESP_V6_FLOW =3D 0x0c, /* hash or spec (esp_ip6_spec; nfc only) */ + IPV4_USER_FLOW =3D 0x0d, /* spec only (usr_ip4_spec) */ + IP_USER_FLOW =3D IPV4_USER_FLOW, + IPV6_USER_FLOW =3D 0x0e, /* spec only (usr_ip6_spec; nfc only) */ + IPV4_FLOW =3D 0x10, /* hash only */ + IPV6_FLOW =3D 0x11, /* hash only */ + ETHER_FLOW =3D 0x12, /* spec only (ether_spec) */ =20 -/* Used for GTP-U IPv4 and IPv6. - * The format of GTP packets only includes - * elements such as TEID and GTP version. - * It is primarily intended for data communication of the UE. - */ -#define GTPU_V4_FLOW 0x13 /* hash only */ -#define GTPU_V6_FLOW 0x14 /* hash only */ + /* Used for GTP-U IPv4 and IPv6. + * The format of GTP packets only includes + * elements such as TEID and GTP version. + * It is primarily intended for data communication of the UE. + */ + GTPU_V4_FLOW =3D 0x13, /* hash only */ + GTPU_V6_FLOW =3D 0x14, /* hash only */ =20 -/* Use for GTP-C IPv4 and v6. - * The format of these GTP packets does not include TEID. - * Primarily expected to be used for communication - * to create sessions for UE data communication, - * commonly referred to as CSR (Create Session Request). - */ -#define GTPC_V4_FLOW 0x15 /* hash only */ -#define GTPC_V6_FLOW 0x16 /* hash only */ + /* Use for GTP-C IPv4 and v6. + * The format of these GTP packets does not include TEID. + * Primarily expected to be used for communication + * to create sessions for UE data communication, + * commonly referred to as CSR (Create Session Request). + */ + GTPC_V4_FLOW =3D 0x15, /* hash only */ + GTPC_V6_FLOW =3D 0x16, /* hash only */ =20 -/* Use for GTP-C IPv4 and v6. - * Unlike GTPC_V4_FLOW, the format of these GTP packets includes TEID. - * After session creation, it becomes this packet. - * This is mainly used for requests to realize UE handover. - */ -#define GTPC_TEID_V4_FLOW 0x17 /* hash only */ -#define GTPC_TEID_V6_FLOW 0x18 /* hash only */ + /* Use for GTP-C IPv4 and v6. + * Unlike GTPC_V4_FLOW, the format of these GTP packets includes TEID. + * After session creation, it becomes this packet. + * This is mainly used for requests to realize UE handover. + */ + GTPC_TEID_V4_FLOW =3D 0x17, /* hash only */ + GTPC_TEID_V6_FLOW =3D 0x18, /* hash only */ =20 -/* Use for GTP-U and extended headers for the PSC (PDU Session Container). - * The format of these GTP packets includes TEID and QFI. - * In 5G communication using UPF (User Plane Function), - * data communication with this extended header is performed. - */ -#define GTPU_EH_V4_FLOW 0x19 /* hash only */ -#define GTPU_EH_V6_FLOW 0x1a /* hash only */ + /* Use for GTP-U and extended headers for the PSC (PDU Session Container). + * The format of these GTP packets includes TEID and QFI. + * In 5G communication using UPF (User Plane Function), + * data communication with this extended header is performed. + */ + GTPU_EH_V4_FLOW =3D 0x19, /* hash only */ + GTPU_EH_V6_FLOW =3D 0x1a, /* hash only */ =20 -/* Use for GTP-U IPv4 and v6 PSC (PDU Session Container) extended headers. - * This differs from GTPU_EH_V(4|6)_FLOW in that it is distinguished by - * UL/DL included in the PSC. - * There are differences in the data included based on Downlink/Uplink, - * and can be used to distinguish packets. - * The functions described so far are useful when you want to - * handle communication from the mobile network in UPF, PGW, etc. - */ -#define GTPU_UL_V4_FLOW 0x1b /* hash only */ -#define GTPU_UL_V6_FLOW 0x1c /* hash only */ -#define GTPU_DL_V4_FLOW 0x1d /* hash only */ -#define GTPU_DL_V6_FLOW 0x1e /* hash only */ + /* Use for GTP-U IPv4 and v6 PSC (PDU Session Container) extended headers. + * This differs from GTPU_EH_V(4|6)_FLOW in that it is distinguished by + * UL/DL included in the PSC. + * There are differences in the data included based on Downlink/Uplink, + * and can be used to distinguish packets. + * The functions described so far are useful when you want to + * handle communication from the mobile network in UPF, PGW, etc. + */ + GTPU_UL_V4_FLOW =3D 0x1b, /* hash only */ + GTPU_UL_V6_FLOW =3D 0x1c, /* hash only */ + GTPU_DL_V4_FLOW =3D 0x1d, /* hash only */ + GTPU_DL_V6_FLOW =3D 0x1e, /* hash only */ + + __FLOW_TYPE_COUNT, +}; =20 /* Flag to enable additional fields in struct ethtool_rx_flow_spec */ #define FLOW_EXT 0x80000000 diff --git a/include/standard-headers/linux/fuse.h b/include/standard-heade= rs/linux/fuse.h index a2b5815d890..d8b2fd67e16 100644 --- a/include/standard-headers/linux/fuse.h +++ b/include/standard-headers/linux/fuse.h @@ -232,6 +232,9 @@ * * 7.43 * - add FUSE_REQUEST_TIMEOUT + * + * 7.44 + * - add FUSE_NOTIFY_INC_EPOCH */ =20 #ifndef _LINUX_FUSE_H @@ -263,7 +266,7 @@ #define FUSE_KERNEL_VERSION 7 =20 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 43 +#define FUSE_KERNEL_MINOR_VERSION 44 =20 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -667,6 +670,7 @@ enum fuse_notify_code { FUSE_NOTIFY_RETRIEVE =3D 5, FUSE_NOTIFY_DELETE =3D 6, FUSE_NOTIFY_RESEND =3D 7, + FUSE_NOTIFY_INC_EPOCH =3D 8, FUSE_NOTIFY_CODE_MAX, }; =20 diff --git a/include/standard-headers/linux/input-event-codes.h b/include/s= tandard-headers/linux/input-event-codes.h index 09ba0ad8783..a82ff795e06 100644 --- a/include/standard-headers/linux/input-event-codes.h +++ b/include/standard-headers/linux/input-event-codes.h @@ -925,7 +925,8 @@ #define SW_MUTE_DEVICE 0x0e /* set =3D device disabled */ #define SW_PEN_INSERTED 0x0f /* set =3D pen inserted */ #define SW_MACHINE_COVER 0x10 /* set =3D cover closed */ -#define SW_MAX_ 0x10 +#define SW_USB_INSERT 0x11 /* set =3D USB audio device connected */ +#define SW_MAX_ 0x11 #define SW_CNT (SW_MAX_+1) =20 /* diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index ba326710f9c..a3a3e942ded 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -750,7 +750,8 @@ #define PCI_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Management */ #define PCI_EXT_CAP_ID_PL_32GT 0x2A /* Physical Layer 32.0 GT/s */ #define PCI_EXT_CAP_ID_DOE 0x2E /* Data Object Exchange */ -#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_DOE +#define PCI_EXT_CAP_ID_PL_64GT 0x31 /* Physical Layer 64.0 GT/s */ +#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_64GT =20 #define PCI_EXT_CAP_DSN_SIZEOF 12 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40 @@ -1144,12 +1145,21 @@ #define PCI_DLF_CAP 0x04 /* Capabilities Register */ #define PCI_DLF_EXCHANGE_ENABLE 0x80000000 /* Data Link Feature Exchange= Enable */ =20 +/* Secondary PCIe Capability 8.0 GT/s */ +#define PCI_SECPCI_LE_CTRL 0x0c /* Lane Equalization Control Register */ + /* Physical Layer 16.0 GT/s */ #define PCI_PL_16GT_LE_CTRL 0x20 /* Lane Equalization Control Register */ #define PCI_PL_16GT_LE_CTRL_DSP_TX_PRESET_MASK 0x0000000F #define PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_MASK 0x000000F0 #define PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_SHIFT 4 =20 +/* Physical Layer 32.0 GT/s */ +#define PCI_PL_32GT_LE_CTRL 0x20 /* Lane Equalization Control Register */ + +/* Physical Layer 64.0 GT/s */ +#define PCI_PL_64GT_LE_CTRL 0x20 /* Lane Equalization Control Register */ + /* Native PCIe Enclosure Management */ #define PCI_NPEM_CAP 0x04 /* NPEM capability register */ #define PCI_NPEM_CAP_CAPABLE 0x00000001 /* NPEM Capable */ diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard= -headers/linux/virtio_gpu.h index 6459fdb9fb5..00cd3f04af9 100644 --- a/include/standard-headers/linux/virtio_gpu.h +++ b/include/standard-headers/linux/virtio_gpu.h @@ -309,8 +309,9 @@ struct virtio_gpu_cmd_submit { =20 #define VIRTIO_GPU_CAPSET_VIRGL 1 #define VIRTIO_GPU_CAPSET_VIRGL2 2 -/* 3 is reserved for gfxstream */ +#define VIRTIO_GPU_CAPSET_GFXSTREAM_VULKAN 3 #define VIRTIO_GPU_CAPSET_VENUS 4 +#define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5 #define VIRTIO_GPU_CAPSET_DRM 6 =20 /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ diff --git a/include/standard-headers/linux/virtio_pci.h b/include/standard= -headers/linux/virtio_pci.h index 91fec6f5029..09e964e6eee 100644 --- a/include/standard-headers/linux/virtio_pci.h +++ b/include/standard-headers/linux/virtio_pci.h @@ -246,6 +246,7 @@ struct virtio_pci_cfg_cap { #define VIRTIO_ADMIN_CMD_LIST_USE 0x1 =20 /* Admin command group type. */ +#define VIRTIO_ADMIN_GROUP_TYPE_SELF 0x0 #define VIRTIO_ADMIN_GROUP_TYPE_SRIOV 0x1 =20 /* Transitional device admin command. */ diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 4e6aff08df8..f4d9baafa1c 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -419,10 +419,11 @@ enum { =20 /* Device Control API on vcpu fd */ #define KVM_ARM_VCPU_PMU_V3_CTRL 0 -#define KVM_ARM_VCPU_PMU_V3_IRQ 0 -#define KVM_ARM_VCPU_PMU_V3_INIT 1 -#define KVM_ARM_VCPU_PMU_V3_FILTER 2 -#define KVM_ARM_VCPU_PMU_V3_SET_PMU 3 +#define KVM_ARM_VCPU_PMU_V3_IRQ 0 +#define KVM_ARM_VCPU_PMU_V3_INIT 1 +#define KVM_ARM_VCPU_PMU_V3_FILTER 2 +#define KVM_ARM_VCPU_PMU_V3_SET_PMU 3 +#define KVM_ARM_VCPU_PMU_V3_SET_NR_COUNTERS 4 #define KVM_ARM_VCPU_TIMER_CTRL 1 #define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0 #define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1 diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 7fb57ccb2a7..cd275ae76d2 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -843,6 +843,7 @@ struct kvm_sev_snp_launch_start { }; =20 /* Kept in sync with firmware values for simplicity. */ +#define KVM_SEV_PAGE_TYPE_INVALID 0x0 #define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1 #define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3 #define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4 diff --git a/linux-headers/linux/bits.h b/linux-headers/linux/bits.h index 58596d18f43..9243f389751 100644 --- a/linux-headers/linux/bits.h +++ b/linux-headers/linux/bits.h @@ -4,9 +4,9 @@ #ifndef _LINUX_BITS_H #define _LINUX_BITS_H =20 -#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG -= 1 - (h)))) +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG= - 1 - (h)))) =20 -#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_= LONG_LONG - 1 - (h)))) +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PE= R_LONG_LONG - 1 - (h)))) =20 #define __GENMASK_U128(h, l) \ ((_BIT128((h)) << 1) - (_BIT128(l))) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 99cc82a275c..0690743944b 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -178,6 +178,7 @@ struct kvm_xen_exit { #define KVM_EXIT_NOTIFY 37 #define KVM_EXIT_LOONGARCH_IOCSR 38 #define KVM_EXIT_MEMORY_FAULT 39 +#define KVM_EXIT_TDX 40 =20 /* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ @@ -439,6 +440,27 @@ struct kvm_run { __u64 gpa; __u64 size; } memory_fault; + /* KVM_EXIT_TDX */ + struct { + __u64 flags; + __u64 nr; + union { + struct { + __u64 ret; + __u64 data[5]; + } unknown; + struct { + __u64 ret; + __u64 gpa; + __u64 size; + } get_quote; + struct { + __u64 ret; + __u64 leaf; + __u64 r11, r12, r13, r14; + } get_tdvmcall_info; + }; + } tdx; /* Fix the size of the union. */ char padding[256]; }; @@ -923,6 +945,9 @@ struct kvm_enable_cap { #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 #define KVM_CAP_ARM_WRITABLE_IMP_ID_REGS 239 +#define KVM_CAP_ARM_EL2 240 +#define KVM_CAP_ARM_EL2_E2H0 241 +#define KVM_CAP_RISCV_MP_STATE_RESET 242 =20 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index b95dd84eef2..d4b3e2ae131 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -28,10 +28,10 @@ =20 /* Set current process as the (exclusive) owner of this file descriptor. = This * must be called before any other vhost command. Further calls to - * VHOST_OWNER_SET fail until VHOST_OWNER_RESET is called. */ + * VHOST_SET_OWNER fail until VHOST_RESET_OWNER is called. */ #define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01) /* Give up ownership, and reset the device to default values. - * Allows subsequent call to VHOST_OWNER_SET to succeed. */ + * Allows subsequent call to VHOST_SET_OWNER to succeed. */ #define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02) =20 /* Set up/modify memory layout */ --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437825; cv=none; d=zohomail.com; s=zohoarc; b=gXEDD3Q1Qd+vgm7HpqJIyX+dildho4ZQeDLZsuYCeBajW59wzkQBk/p8I8DD6QFm1klcpGcku9EkwcuGPmfXQuyYSHwed1cqdUtHaUNqb0oJkBdsffiCihPZZAOREJrBQFliCTBlC99l85AeTlGywzP00ut6ZetDvIp3PlZ+qzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437825; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bPyEsEyR+eeawbg8Mgoqk136AaGHZYCr52XL3CFj5p0=; b=h6uTpeOmQzA6ZenHBEvhGuSiGGydXSE8CTTc0XtxU7NDjA9gOtRrwEDSLLG6MeHNAk3BzeMkhHOzw0TmHG+fFbmr5AHrD5k/2LC6PNj9Wa3SlXABtkXyFUNzTgnVrxGSagm8hnMpZhbjbZ081Lxu/XfGx4VvaaOTEHJ5TNObtSo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437825287555.8703620992519; Fri, 20 Jun 2025 09:43:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeos-0007p2-4C; Fri, 20 Jun 2025 12:42:26 -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 1uSeoa-0007Aw-6c for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeoY-0000NU-ME for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:07 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-466-0wsDLc3ePbW9x2OKeL9xwQ-1; Fri, 20 Jun 2025 12:42:04 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-607c91a207dso1833170a12.2 for ; Fri, 20 Jun 2025 09:42:04 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60a18d0e561sm1645327a12.81.2025.06.20.09.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bPyEsEyR+eeawbg8Mgoqk136AaGHZYCr52XL3CFj5p0=; b=ij/bELWj6L/urAMxxV73tsrdV4S6aXb333vrBp9ivz10ZevARosoVl6MmgRozmLaiyq35V PuM0W+F8HVKH2oA80PO78u45XlC60rqEc+z/8O8ZGByP9734FM19Bk2vWrsGF4xDQrx6c+ +yWTe+wVF16ia+CHO9nXNva/qlvw0Tc= X-MC-Unique: 0wsDLc3ePbW9x2OKeL9xwQ-1 X-Mimecast-MFC-AGG-ID: 0wsDLc3ePbW9x2OKeL9xwQ_1750437723 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437722; x=1751042522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bPyEsEyR+eeawbg8Mgoqk136AaGHZYCr52XL3CFj5p0=; b=wqB4mkPAVnjA1rsr6dBuR4XYPphxEVpRVs3IHLkmszL1tGu3LP0GvbmKZ720glugNN MH29keW1rkk7Ll3Xp+ewP4EKRLqrzKQHyCvZUCYsQ+Mq7ZPSgNlpH/6p1/9Pwo4oM9XL fMKICQSJcJZPkUeyNZZJsdO0zFFi2njskWGitDZA+0z+P4PnizisUX9pk6F7nlLrPiru Oy4MMcaHMWB//wngbxulYjUe5D7YdjnfY2Z1pVTXhNVyCA98sZhIttqBF4eOtE8OrF5Q NxfiScIPpeEdUZ0CkS58GZ82YD4x5sfnOs4VFHDpOA4PxoXL66Re7Of6j1zHHnHciw6q p0mg== X-Gm-Message-State: AOJu0Yw7AuZYXMCfk+kft4exJkbiqnNg+fagPXshzaG91EcCRTEhHcUy vIlFNXGGErCIY+HDBNOoEIQ2yeGOZ/XR8QcZ/EZjRnN0TD3NqvVcr4XPIGbRzzAlhLDlyfId29P kb3AiktlZl8ixoftJABqmX9NLaS9vPc3dM8mnGoUAttxa7ozhYMPjBXlqTA0DvTuk6+LJVpvyoG EQi1uuW/D2ocM+noo495rN/V9iNu/rJS20sL27lXiL X-Gm-Gg: ASbGncuyeVRH9U3lzEaB24tRxhpw7Z5HTYCe8qnaY/PZNF8wFxKSvAsbH6is+w2L0DR kB/7UyhV/yE8FANxjRvka2wGPW0x8+irdEpcFh1AlZ4qfTmqrKjEjeOwCczbnu1ofnuP/baSyQQ y4szw4YqJFAsgKi2pM94RYy3j/tjBPm4+A21WLDo9MjR+14BFHUWw0Htw5PGlI5NtaLeWONfgU1 WeeOfqEmxM7awhG4O21Ihb/k1FQT7Bupjh+klgontYTwR6ProUrHAI7jgnq1+VJwVUJBhiMqQwP INa53uR52fTm2+lsEts9TpoGaw== X-Received: by 2002:a05:6402:50c9:b0:604:bbd2:7c6c with SMTP id 4fb4d7f45d1cf-60a1d19192amr3403845a12.27.1750437722639; Fri, 20 Jun 2025 09:42:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlz6BoAxCUEJjgcQa1ACErmLeWI4wLoFzZZK2Fthe2g3GPIjgK2aifLaLOGdbU1tSyl9icQg== X-Received: by 2002:a05:6402:50c9:b0:604:bbd2:7c6c with SMTP id 4fb4d7f45d1cf-60a1d19192amr3403816a12.27.1750437722107; Fri, 20 Jun 2025 09:42:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Binbin Wu Subject: [PULL 23/24] i386/tdx: handle TDG.VP.VMCALL Date: Fri, 20 Jun 2025 18:40:51 +0200 Message-ID: <20250620164053.579416-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437826330116600 Content-Type: text/plain; charset="utf-8" From: Binbin Wu Signed-off-by: Binbin Wu Signed-off-by: Paolo Bonzini --- target/i386/kvm/tdx.h | 9 +++++++++ target/i386/kvm/kvm.c | 12 ++++++++++++ target/i386/kvm/tdx-stub.c | 4 ++++ target/i386/kvm/tdx.c | 12 ++++++++++++ 4 files changed, 37 insertions(+) diff --git a/target/i386/kvm/tdx.h b/target/i386/kvm/tdx.h index 8dd66e90149..0dd41d5811a 100644 --- a/target/i386/kvm/tdx.h +++ b/target/i386/kvm/tdx.h @@ -21,6 +21,14 @@ typedef struct TdxGuestClass { /* TDX requires bus frequency 25MHz */ #define TDX_APIC_BUS_CYCLES_NS 40 =20 +#define TDVMCALL_GET_TD_VM_CALL_INFO 0x10000 + +#define TDG_VP_VMCALL_SUCCESS 0x0000000000000000ULL +#define TDG_VP_VMCALL_RETRY 0x0000000000000001ULL +#define TDG_VP_VMCALL_INVALID_OPERAND 0x8000000000000000ULL +#define TDG_VP_VMCALL_GPA_INUSE 0x8000000000000001ULL +#define TDG_VP_VMCALL_ALIGN_ERROR 0x8000000000000002ULL + enum TdxRamType { TDX_RAM_UNACCEPTED, TDX_RAM_ADDED, @@ -61,5 +69,6 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp); void tdx_set_tdvf_region(MemoryRegion *tdvf_mr); int tdx_parse_tdvf(void *flash_ptr, int size); int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run); +void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run); =20 #endif /* QEMU_I386_TDX_H */ diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 56a6b9b6381..8ef29fc1fb1 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6170,6 +6170,18 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_ru= n *run) break; } break; + case KVM_EXIT_TDX: + /* + * run->tdx is already set up for the case where userspace + * does not handle the TDVMCALL. + */ + switch (run->tdx.nr) { + case TDVMCALL_GET_TD_VM_CALL_INFO: + tdx_handle_get_tdvmcall_info(cpu, run); + break; + } + ret =3D 0; + break; default: fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason); ret =3D -1; diff --git a/target/i386/kvm/tdx-stub.c b/target/i386/kvm/tdx-stub.c index 720a4ff046e..62a12a06775 100644 --- a/target/i386/kvm/tdx-stub.c +++ b/target/i386/kvm/tdx-stub.c @@ -18,3 +18,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm= _run *run) { return -EINVAL; } + +void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) +{ +} diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 2284167141a..ef10a193474 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -1120,6 +1120,18 @@ int tdx_parse_tdvf(void *flash_ptr, int size) return tdvf_parse_metadata(&tdx_guest->tdvf, flash_ptr, size); } =20 +void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) +{ + if (run->tdx.get_tdvmcall_info.leaf !=3D 1) { + return; + } + + run->tdx.get_tdvmcall_info.r11 =3D 0; + run->tdx.get_tdvmcall_info.r12 =3D 0; + run->tdx.get_tdvmcall_info.r13 =3D 0; + run->tdx.get_tdvmcall_info.r14 =3D 0; +} + static void tdx_panicked_on_fatal_error(X86CPU *cpu, uint64_t error_code, char *message, uint64_t gpa) { --=20 2.49.0 From nobody Sat Nov 15 14:51:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750437844; cv=none; d=zohomail.com; s=zohoarc; b=c0c0NmkA0KVV+QR4xVGDtzgUt3wK2koxGx3OqQtWEDPTd+WuXLUoYniV4fipw7ZQm54j0znmpOFhNJGXy36/+IaHgYHp2nGgHguyYi39o5kw4kIHSn7LEqJScdsaZMp00TFuuxsmo+W3pL5Ami6t1MhQR5N+ixY89ZFBTnw2L3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750437844; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TPCtgHjjOME3wbK++PbqYUj6+yZcq+ob9E7eKp76/bs=; b=BBGFdVbs/zk3rT1RLIrZ8kDqghYym7QVkeObHo7XYpoH8SrTBjbLBsZa2m+umbBXtQX3ez8C5GYqGrIl0zPXdXmSngj4oUls7Z+KEGpn3R3fQpIfD/V9x9Y9Y637orbYGfsBDtfUZmPF7LLySRrvyHhVHqI9gEXlU4M5tTaLy98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750437844438807.1527962722803; Fri, 20 Jun 2025 09:44:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uSeos-0007sU-DH; Fri, 20 Jun 2025 12:42:26 -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 1uSeoj-0007MO-1b for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSeog-0000Ob-2B for qemu-devel@nongnu.org; Fri, 20 Jun 2025 12:42:16 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-uVr6mXvEOKC_nfclJ_a2MQ-1; Fri, 20 Jun 2025 12:42:10 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-ade6db50bb4so147938366b.2 for ; Fri, 20 Jun 2025 09:42:10 -0700 (PDT) Received: from [192.168.122.1] ([151.62.200.93]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae053ee4c90sm188996866b.62.2025.06.20.09.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jun 2025 09:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750437732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TPCtgHjjOME3wbK++PbqYUj6+yZcq+ob9E7eKp76/bs=; b=LIT29kQhHyoQ4cwIao0Hk8g716voZaGUtwVD/YgkNdiuvpPqrTuNWW04Uq6BV5/NqJpFsX roJyppfZD85Pqil3ewlBLEzhF5yi8/RVeuk89c08e5YdWPs7kgdnKMHyU/3OD6VXcxcO+O JHspICStB7FHyGZYMml+5ax8BnDXNrk= X-MC-Unique: uVr6mXvEOKC_nfclJ_a2MQ-1 X-Mimecast-MFC-AGG-ID: uVr6mXvEOKC_nfclJ_a2MQ_1750437729 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750437728; x=1751042528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPCtgHjjOME3wbK++PbqYUj6+yZcq+ob9E7eKp76/bs=; b=MpIaurjcXZTsB3xBLCSp+eYqUlYYp2sN/dhpxOKNg0pEPyNeLmkuq7rSijROO3O0RJ JjxQMH1oLGA2eILMQn/TUYf+z3Gdo66QzLCSdjco+hetJfLbc2hwClQIfmR4q8fTT8Il BdgzJygjo01iW/6XXtYr5y0fZ0HTriUD8sdanrUXDTjTMvdkDQIMuLkhtFmjuAMD06Y3 rra1L83KR0fEPT033ODYmzBPYBuUBpA7AoyGG+d3UJ/SBR/2uSSpPzTiYfKw1d8zOt0D kgEzkIx1Bg4CEJh4WwrFrjv4YgRv52OWncOreBSeCsi+pibOqcBY5kFeP/Tp7bYIOSY7 JsPA== X-Gm-Message-State: AOJu0YwXA6do4VrJrjxrXTmEnkzWKLtx0BPL82UNaH5/OOqn0dEGw5yX 3qSMls6uglOIB9/6WcSD8/S5urqAUzjYv89bjOWLi+yzReqevhMdiMJT91fe1PGdAy5z7l5cGTM zi/KK/bfftbHU4rJFU5jh6H14oWNm4vnAUqMewOy8g74jHZgSTNIF2snvs6bN8I7gLcdB/6kq9l GzDAajCKpdl0mxSxjMMTNB+NLyotI1wkzM9GpX6czg X-Gm-Gg: ASbGncsXVDAeMh54Wxeh76aSfJ3kW/h0l1+vBRyMZ9phnoFKADzNPOM2CQcGRhR59nI HMi82VwwEYPth+vtTDS3CQowM+fmfvMYDlY9Ie854kweEC4/mUhgH2Z1b2Zfg82csqOaQC2lWHa GFVQTJHDJEbEZdToRX7rYzRmaFucCUs2G/FL0XrnnHcEZ2R79K9Q6PGK4yFuUHyD/6bbkmInGjc UYNEWxbMjUjWh5zCXy3Og0FrpnzkmYjuDz6nfPRY3xQlCOen0DJ7GFH6JeGglsniq10rdAPK53t AwAHKacxc3qUUfC4B1N51r71QA== X-Received: by 2002:a17:907:fdcb:b0:ad2:4b33:ae70 with SMTP id a640c23a62f3a-ae057c0f5d5mr367838966b.31.1750437728068; Fri, 20 Jun 2025 09:42:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyL2HHn4raOZ65Ul4V94olhusxFKQi4bRQ3UMdtRDDSnDCCp64kl9NzDU2Eh/teWPEZCYDNg== X-Received: by 2002:a17:907:fdcb:b0:ad2:4b33:ae70 with SMTP id a640c23a62f3a-ae057c0f5d5mr367835766b.31.1750437727389; Fri, 20 Jun 2025 09:42:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Isaku Yamahata , Chenyi Qiang , Xiaoyao Li Subject: [PULL 24/24] i386/tdx: handle TDG.VP.VMCALL Date: Fri, 20 Jun 2025 18:40:52 +0200 Message-ID: <20250620164053.579416-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250620164053.579416-1-pbonzini@redhat.com> References: <20250620164053.579416-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.897, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1750437846994116600 Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata Add property "quote-generation-socket" to tdx-guest, which is a property of type SocketAddress to specify Quote Generation Service(QGS). On request of GetQuote, it connects to the QGS socket, read request data from shared guest memory, send the request data to the QGS, and store the response into shared guest memory, at last notify TD guest by interrupt. command line example: qemu-system-x86_64 \ -object '{"qom-type":"tdx-guest","id":"tdx0","quote-generation-socket":= {"type":"unix", "path":"/var/run/tdx-qgs/qgs.socket"}}' \ -machine confidential-guest-support=3Dtdx0 Note, above example uses the unix socket. It can be other types, like vsock, which depends on the implementation of QGS. To avoid no response from QGS server, setup a timer for the transaction. If timeout, make it an error and interrupt guest. Define the threshold of time to 30s at present, maybe change to other value if not appropriate. Signed-off-by: Isaku Yamahata Co-developed-by: Chenyi Qiang Signed-off-by: Chenyi Qiang Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Tested-by: Xiaoyao Li Signed-off-by: Paolo Bonzini --- qapi/qom.json | 8 +- target/i386/kvm/tdx-quote-generator.h | 82 +++++++ target/i386/kvm/tdx.h | 10 + target/i386/kvm/kvm.c | 3 + target/i386/kvm/tdx-quote-generator.c | 300 ++++++++++++++++++++++++++ target/i386/kvm/tdx-stub.c | 4 + target/i386/kvm/tdx.c | 176 ++++++++++++++- target/i386/kvm/meson.build | 2 +- 8 files changed, 582 insertions(+), 3 deletions(-) create mode 100644 target/i386/kvm/tdx-quote-generator.h create mode 100644 target/i386/kvm/tdx-quote-generator.c diff --git a/qapi/qom.json b/qapi/qom.json index 3e8debf78c2..b133b064471 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -1071,6 +1071,11 @@ # e.g., specific to the workload rather than the run-time or OS # (base64 encoded SHA384 digest). Defaults to all zeros. # +# @quote-generation-socket: socket address for Quote Generation +# Service (QGS). QGS is a daemon running on the host. Without +# it, the guest will not be able to get a TD quote for +# attestation. +# # Since: 10.1 ## { 'struct': 'TdxGuestProperties', @@ -1078,7 +1083,8 @@ '*sept-ve-disable': 'bool', '*mrconfigid': 'str', '*mrowner': 'str', - '*mrownerconfig': 'str' } } + '*mrownerconfig': 'str', + '*quote-generation-socket': 'SocketAddress' } } =20 ## # @ThreadContextProperties: diff --git a/target/i386/kvm/tdx-quote-generator.h b/target/i386/kvm/tdx-qu= ote-generator.h new file mode 100644 index 00000000000..3bd9b8ef331 --- /dev/null +++ b/target/i386/kvm/tdx-quote-generator.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef QEMU_I386_TDX_QUOTE_GENERATOR_H +#define QEMU_I386_TDX_QUOTE_GENERATOR_H + +#include "qom/object_interfaces.h" +#include "io/channel-socket.h" +#include "exec/hwaddr.h" + +#define TDX_GET_QUOTE_STRUCTURE_VERSION 1ULL + +#define TDX_VP_GET_QUOTE_SUCCESS 0ULL +#define TDX_VP_GET_QUOTE_IN_FLIGHT (-1ULL) +#define TDX_VP_GET_QUOTE_ERROR 0x8000000000000000ULL +#define TDX_VP_GET_QUOTE_QGS_UNAVAILABLE 0x8000000000000001ULL + +/* Limit to avoid resource starvation. */ +#define TDX_GET_QUOTE_MAX_BUF_LEN (128 * 1024) +#define TDX_MAX_GET_QUOTE_REQUEST 16 + +#define TDX_GET_QUOTE_HDR_SIZE 24 + +/* Format of pages shared with guest. */ +struct tdx_get_quote_header { + /* Format version: must be 1 in little endian. */ + uint64_t structure_version; + + /* + * GetQuote status code in little endian: + * Guest must set error_code to 0 to avoid information leak. + * Qemu sets this before interrupting guest. + */ + uint64_t error_code; + + /* + * in-message size in little endian: The message will follow this head= er. + * The in-message will be send to QGS. + */ + uint32_t in_len; + + /* + * out-message size in little endian: + * On request, out_len must be zero to avoid information leak. + * On return, message size from QGS. Qemu overwrites this field. + * The message will follows this header. The in-message is overwritte= n. + */ + uint32_t out_len; + + /* + * Message buffer follows. + * Guest sets message that will be send to QGS. If out_len > in_len, = guest + * should zero remaining buffer to avoid information leak. + * Qemu overwrites this buffer with a message returned from QGS. + */ +}; + +typedef struct TdxGenerateQuoteTask { + hwaddr buf_gpa; + hwaddr payload_gpa; + uint64_t payload_len; + + char *send_data; + uint64_t send_data_size; + uint64_t send_data_sent; + + char *receive_buf; + uint64_t receive_buf_received; + + uint64_t status_code; + struct tdx_get_quote_header hdr; + + QIOChannelSocket *sioc; + guint watch; + QEMUTimer timer; + + void (*completion)(struct TdxGenerateQuoteTask *task); + void *opaque; +} TdxGenerateQuoteTask; + +void tdx_generate_quote(TdxGenerateQuoteTask *task, SocketAddress *qg_sock= _addr); + +#endif /* QEMU_I386_TDX_QUOTE_GENERATOR_H */ diff --git a/target/i386/kvm/tdx.h b/target/i386/kvm/tdx.h index 0dd41d5811a..35a09c19c52 100644 --- a/target/i386/kvm/tdx.h +++ b/target/i386/kvm/tdx.h @@ -11,6 +11,8 @@ #include "cpu.h" #include "hw/i386/tdvf.h" =20 +#include "tdx-quote-generator.h" + #define TYPE_TDX_GUEST "tdx-guest" #define TDX_GUEST(obj) OBJECT_CHECK(TdxGuest, (obj), TYPE_TDX_GUEST) =20 @@ -22,6 +24,7 @@ typedef struct TdxGuestClass { #define TDX_APIC_BUS_CYCLES_NS 40 =20 #define TDVMCALL_GET_TD_VM_CALL_INFO 0x10000 +#define TDVMCALL_GET_QUOTE 0x10002 =20 #define TDG_VP_VMCALL_SUCCESS 0x0000000000000000ULL #define TDG_VP_VMCALL_RETRY 0x0000000000000001ULL @@ -29,6 +32,8 @@ typedef struct TdxGuestClass { #define TDG_VP_VMCALL_GPA_INUSE 0x8000000000000001ULL #define TDG_VP_VMCALL_ALIGN_ERROR 0x8000000000000002ULL =20 +#define TDG_VP_VMCALL_SUBFUNC_GET_QUOTE 0x0000000000000001ULL + enum TdxRamType { TDX_RAM_UNACCEPTED, TDX_RAM_ADDED, @@ -57,6 +62,10 @@ typedef struct TdxGuest { =20 uint32_t nr_ram_entries; TdxRamEntry *ram_entries; + + /* GetQuote */ + SocketAddress *qg_sock_addr; + int num; } TdxGuest; =20 #ifdef CONFIG_TDX @@ -69,6 +78,7 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp); void tdx_set_tdvf_region(MemoryRegion *tdvf_mr); int tdx_parse_tdvf(void *flash_ptr, int size); int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run); +void tdx_handle_get_quote(X86CPU *cpu, struct kvm_run *run); void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run); =20 #endif /* QEMU_I386_TDX_H */ diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 8ef29fc1fb1..234878c613f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6176,6 +6176,9 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) * does not handle the TDVMCALL. */ switch (run->tdx.nr) { + case TDVMCALL_GET_QUOTE: + tdx_handle_get_quote(cpu, run); + break; case TDVMCALL_GET_TD_VM_CALL_INFO: tdx_handle_get_tdvmcall_info(cpu, run); break; diff --git a/target/i386/kvm/tdx-quote-generator.c b/target/i386/kvm/tdx-qu= ote-generator.c new file mode 100644 index 00000000000..f59715f6175 --- /dev/null +++ b/target/i386/kvm/tdx-quote-generator.c @@ -0,0 +1,300 @@ +/* + * QEMU TDX Quote Generation Support + * + * Copyright (c) 2025 Intel Corporation + * + * Author: + * Xiaoyao Li + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "qapi/qapi-visit-sockets.h" + +#include "tdx-quote-generator.h" + +#define QGS_MSG_LIB_MAJOR_VER 1 +#define QGS_MSG_LIB_MINOR_VER 1 + +typedef enum _qgs_msg_type_t { + GET_QUOTE_REQ =3D 0, + GET_QUOTE_RESP =3D 1, + GET_COLLATERAL_REQ =3D 2, + GET_COLLATERAL_RESP =3D 3, + GET_PLATFORM_INFO_REQ =3D 4, + GET_PLATFORM_INFO_RESP =3D 5, + QGS_MSG_TYPE_MAX +} qgs_msg_type_t; + +typedef struct _qgs_msg_header_t { + uint16_t major_version; + uint16_t minor_version; + uint32_t type; + uint32_t size; // size of the whole message, include this= header, in byte + uint32_t error_code; // used in response only +} qgs_msg_header_t; + +typedef struct _qgs_msg_get_quote_req_t { + qgs_msg_header_t header; // header.type =3D GET_QUOTE_REQ + uint32_t report_size; // cannot be 0 + uint32_t id_list_size; // length of id_list, in byte, can be 0 +} qgs_msg_get_quote_req_t; + +typedef struct _qgs_msg_get_quote_resp_s { + qgs_msg_header_t header; // header.type =3D GET_QUOTE_RESP + uint32_t selected_id_size; // can be 0 in case only one id is sent in= request + uint32_t quote_size; // length of quote_data, in byte + uint8_t id_quote[]; // selected id followed by quote +} qgs_msg_get_quote_resp_t; + +#define HEADER_SIZE 4 + +static uint32_t decode_header(const char *buf, size_t len) { + if (len < HEADER_SIZE) { + return 0; + } + uint32_t msg_size =3D 0; + for (uint32_t i =3D 0; i < HEADER_SIZE; ++i) { + msg_size =3D msg_size * 256 + (buf[i] & 0xFF); + } + return msg_size; +} + +static void encode_header(char *buf, size_t len, uint32_t size) { + assert(len >=3D HEADER_SIZE); + buf[0] =3D ((size >> 24) & 0xFF); + buf[1] =3D ((size >> 16) & 0xFF); + buf[2] =3D ((size >> 8) & 0xFF); + buf[3] =3D (size & 0xFF); +} + +static void tdx_generate_quote_cleanup(TdxGenerateQuoteTask *task) +{ + timer_del(&task->timer); + + g_source_remove(task->watch); + qio_channel_close(QIO_CHANNEL(task->sioc), NULL); + object_unref(OBJECT(task->sioc)); + + task->completion(task); +} + +static gboolean tdx_get_quote_read(QIOChannel *ioc, GIOCondition condition, + gpointer opaque) +{ + TdxGenerateQuoteTask *task =3D opaque; + Error *err =3D NULL; + int ret; + + ret =3D qio_channel_read(ioc, task->receive_buf + task->receive_buf_re= ceived, + task->payload_len - task->receive_buf_received,= &err); + if (ret < 0) { + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + return G_SOURCE_CONTINUE; + } else { + error_report_err(err); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + } + + if (ret =3D=3D 0) { + error_report("End of file before reply received"); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + + task->receive_buf_received +=3D ret; + if (task->receive_buf_received >=3D HEADER_SIZE) { + uint32_t len =3D decode_header(task->receive_buf, + task->receive_buf_received); + if (len =3D=3D 0 || + len > (task->payload_len - HEADER_SIZE)) { + error_report("Message len %u must be non-zero & less than %zu", + len, (task->payload_len - HEADER_SIZE)); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + + /* Now we know the size, shrink to fit */ + task->payload_len =3D HEADER_SIZE + len; + task->receive_buf =3D g_renew(char, + task->receive_buf, + task->payload_len); + } + + if (task->receive_buf_received >=3D (sizeof(qgs_msg_header_t) + HEADER= _SIZE)) { + qgs_msg_header_t *hdr =3D (qgs_msg_header_t *)(task->receive_buf += HEADER_SIZE); + if (hdr->major_version !=3D QGS_MSG_LIB_MAJOR_VER || + hdr->minor_version !=3D QGS_MSG_LIB_MINOR_VER) { + error_report("Invalid QGS message header version %d.%d", + hdr->major_version, + hdr->minor_version); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + if (hdr->type !=3D GET_QUOTE_RESP) { + error_report("Invalid QGS message type %d", + hdr->type); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + if (hdr->size > (task->payload_len - HEADER_SIZE)) { + error_report("QGS message size %d exceeds payload capacity %zu= ", + hdr->size, task->payload_len); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + if (hdr->error_code !=3D 0) { + error_report("QGS message error code %d", + hdr->error_code); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + } + if (task->receive_buf_received >=3D (sizeof(qgs_msg_get_quote_resp_t) = + HEADER_SIZE)) { + qgs_msg_get_quote_resp_t *msg =3D (qgs_msg_get_quote_resp_t *)(tas= k->receive_buf + HEADER_SIZE); + if (msg->selected_id_size !=3D 0) { + error_report("QGS message selected ID was %d not 0", + msg->selected_id_size); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + + if ((task->payload_len - HEADER_SIZE - sizeof(qgs_msg_get_quote_re= sp_t)) !=3D + msg->quote_size) { + error_report("QGS quote size %d should be %zu", + msg->quote_size, + (task->payload_len - sizeof(qgs_msg_get_quote_res= p_t))); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + goto end; + } + } + + if (task->receive_buf_received =3D=3D task->payload_len) { + size_t strip =3D HEADER_SIZE + sizeof(qgs_msg_get_quote_resp_t); + memmove(task->receive_buf, + task->receive_buf + strip, + task->receive_buf_received - strip); + task->receive_buf_received -=3D strip; + task->status_code =3D TDX_VP_GET_QUOTE_SUCCESS; + goto end; + } + + return G_SOURCE_CONTINUE; + +end: + tdx_generate_quote_cleanup(task); + return G_SOURCE_REMOVE; +} + +static gboolean tdx_send_report(QIOChannel *ioc, GIOCondition condition, + gpointer opaque) +{ + TdxGenerateQuoteTask *task =3D opaque; + Error *err =3D NULL; + int ret; + + ret =3D qio_channel_write(ioc, task->send_data + task->send_data_sent, + task->send_data_size - task->send_data_sent, &= err); + if (ret < 0) { + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + ret =3D 0; + } else { + error_report_err(err); + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + tdx_generate_quote_cleanup(task); + goto end; + } + } + task->send_data_sent +=3D ret; + + if (task->send_data_sent =3D=3D task->send_data_size) { + task->watch =3D qio_channel_add_watch(QIO_CHANNEL(task->sioc), G_I= O_IN, + tdx_get_quote_read, task, NULL= ); + goto end; + } + + return G_SOURCE_CONTINUE; + +end: + return G_SOURCE_REMOVE; +} + +static void tdx_quote_generator_connected(QIOTask *qio_task, gpointer opaq= ue) +{ + TdxGenerateQuoteTask *task =3D opaque; + Error *err =3D NULL; + int ret; + + ret =3D qio_task_propagate_error(qio_task, &err); + if (ret) { + error_report_err(err); + task->status_code =3D TDX_VP_GET_QUOTE_QGS_UNAVAILABLE; + tdx_generate_quote_cleanup(task); + return; + } + + task->watch =3D qio_channel_add_watch(QIO_CHANNEL(task->sioc), G_IO_OU= T, + tdx_send_report, task, NULL); +} + +#define TRANSACTION_TIMEOUT 30000 + +static void getquote_expired(void *opaque) +{ + TdxGenerateQuoteTask *task =3D opaque; + + task->status_code =3D TDX_VP_GET_QUOTE_ERROR; + tdx_generate_quote_cleanup(task); +} + +static void setup_get_quote_timer(TdxGenerateQuoteTask *task) +{ + int64_t time; + + timer_init_ms(&task->timer, QEMU_CLOCK_VIRTUAL, getquote_expired, task= ); + time =3D qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); + timer_mod(&task->timer, time + TRANSACTION_TIMEOUT); +} + +void tdx_generate_quote(TdxGenerateQuoteTask *task, + SocketAddress *qg_sock_addr) +{ + QIOChannelSocket *sioc; + qgs_msg_get_quote_req_t msg; + + /* Prepare a QGS message prelude */ + msg.header.major_version =3D QGS_MSG_LIB_MAJOR_VER; + msg.header.minor_version =3D QGS_MSG_LIB_MINOR_VER; + msg.header.type =3D GET_QUOTE_REQ; + msg.header.size =3D sizeof(msg) + task->send_data_size; + msg.header.error_code =3D 0; + msg.report_size =3D task->send_data_size; + msg.id_list_size =3D 0; + + /* Make room to add the QGS message prelude */ + task->send_data =3D g_renew(char, + task->send_data, + task->send_data_size + sizeof(msg) + HEADER_= SIZE); + memmove(task->send_data + sizeof(msg) + HEADER_SIZE, + task->send_data, + task->send_data_size); + memcpy(task->send_data + HEADER_SIZE, + &msg, + sizeof(msg)); + encode_header(task->send_data, HEADER_SIZE, task->send_data_size + siz= eof(msg)); + task->send_data_size +=3D sizeof(msg) + HEADER_SIZE; + + sioc =3D qio_channel_socket_new(); + task->sioc =3D sioc; + + setup_get_quote_timer(task); + + qio_channel_socket_connect_async(sioc, qg_sock_addr, + tdx_quote_generator_connected, task, + NULL, NULL); +} diff --git a/target/i386/kvm/tdx-stub.c b/target/i386/kvm/tdx-stub.c index 62a12a06775..76fee49eff0 100644 --- a/target/i386/kvm/tdx-stub.c +++ b/target/i386/kvm/tdx-stub.c @@ -19,6 +19,10 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct kv= m_run *run) return -EINVAL; } =20 +void tdx_handle_get_quote(X86CPU *cpu, struct kvm_run *run) +{ +} + void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) { } diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index ef10a193474..e809e4b2dfa 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -14,12 +14,14 @@ #include "qemu/base64.h" #include "qemu/mmap-alloc.h" #include "qapi/error.h" +#include "qapi/qapi-visit-sockets.h" #include "qom/object_interfaces.h" #include "crypto/hash.h" #include "system/kvm_int.h" #include "system/runstate.h" #include "system/system.h" #include "system/ramblock.h" +#include "system/address-spaces.h" =20 #include =20 @@ -32,6 +34,7 @@ #include "hw/i386/tdvf-hob.h" #include "kvm_i386.h" #include "tdx.h" +#include "tdx-quote-generator.h" =20 #include "standard-headers/asm-x86/kvm_para.h" =20 @@ -1120,13 +1123,146 @@ int tdx_parse_tdvf(void *flash_ptr, int size) return tdvf_parse_metadata(&tdx_guest->tdvf, flash_ptr, size); } =20 +static void tdx_get_quote_completion(TdxGenerateQuoteTask *task) +{ + TdxGuest *tdx =3D task->opaque; + int ret; + + /* Maintain the number of in-flight requests. */ + qemu_mutex_lock(&tdx->lock); + tdx->num--; + qemu_mutex_unlock(&tdx->lock); + + if (task->status_code =3D=3D TDX_VP_GET_QUOTE_SUCCESS) { + ret =3D address_space_write(&address_space_memory, task->payload_g= pa, + MEMTXATTRS_UNSPECIFIED, task->receive_bu= f, + task->receive_buf_received); + if (ret !=3D MEMTX_OK) { + error_report("TDX: get-quote: failed to write quote data."); + } else { + task->hdr.out_len =3D cpu_to_le64(task->receive_buf_received); + } + } + task->hdr.error_code =3D cpu_to_le64(task->status_code); + + /* Publish the response contents before marking this request completed= . */ + smp_wmb(); + ret =3D address_space_write(&address_space_memory, task->buf_gpa, + MEMTXATTRS_UNSPECIFIED, &task->hdr, + TDX_GET_QUOTE_HDR_SIZE); + if (ret !=3D MEMTX_OK) { + error_report("TDX: get-quote: failed to update GetQuote header."); + } + + g_free(task->send_data); + g_free(task->receive_buf); + g_free(task); + object_unref(tdx); +} + +void tdx_handle_get_quote(X86CPU *cpu, struct kvm_run *run) +{ + TdxGenerateQuoteTask *task; + struct tdx_get_quote_header hdr; + hwaddr buf_gpa =3D run->tdx.get_quote.gpa; + uint64_t buf_len =3D run->tdx.get_quote.size; + + QEMU_BUILD_BUG_ON(sizeof(struct tdx_get_quote_header) !=3D TDX_GET_QUO= TE_HDR_SIZE); + + run->tdx.get_quote.ret =3D TDG_VP_VMCALL_INVALID_OPERAND; + + if (buf_len =3D=3D 0) { + return; + } + + if (!QEMU_IS_ALIGNED(buf_gpa, 4096) || !QEMU_IS_ALIGNED(buf_len, 4096)= ) { + run->tdx.get_quote.ret =3D TDG_VP_VMCALL_ALIGN_ERROR; + return; + } + + if (address_space_read(&address_space_memory, buf_gpa, MEMTXATTRS_UNSP= ECIFIED, + &hdr, TDX_GET_QUOTE_HDR_SIZE) !=3D MEMTX_OK) { + error_report("TDX: get-quote: failed to read GetQuote header."); + return; + } + + if (le64_to_cpu(hdr.structure_version) !=3D TDX_GET_QUOTE_STRUCTURE_VE= RSION) { + return; + } + + /* Only safe-guard check to avoid too large buffer size. */ + if (buf_len > TDX_GET_QUOTE_MAX_BUF_LEN || + le32_to_cpu(hdr.in_len) > buf_len - TDX_GET_QUOTE_HDR_SIZE) { + return; + } + + if (!tdx_guest->qg_sock_addr) { + hdr.error_code =3D cpu_to_le64(TDX_VP_GET_QUOTE_QGS_UNAVAILABLE); + if (address_space_write(&address_space_memory, buf_gpa, + MEMTXATTRS_UNSPECIFIED, + &hdr, TDX_GET_QUOTE_HDR_SIZE) !=3D MEMTX_O= K) { + error_report("TDX: failed to update GetQuote header."); + return; + } + run->tdx.get_quote.ret =3D TDG_VP_VMCALL_SUCCESS; + return; + } + + qemu_mutex_lock(&tdx_guest->lock); + if (tdx_guest->num >=3D TDX_MAX_GET_QUOTE_REQUEST) { + qemu_mutex_unlock(&tdx_guest->lock); + run->tdx.get_quote.ret =3D TDG_VP_VMCALL_RETRY; + return; + } + tdx_guest->num++; + qemu_mutex_unlock(&tdx_guest->lock); + + task =3D g_new(TdxGenerateQuoteTask, 1); + task->buf_gpa =3D buf_gpa; + task->payload_gpa =3D buf_gpa + TDX_GET_QUOTE_HDR_SIZE; + task->payload_len =3D buf_len - TDX_GET_QUOTE_HDR_SIZE; + task->hdr =3D hdr; + task->completion =3D tdx_get_quote_completion; + + task->send_data_size =3D le32_to_cpu(hdr.in_len); + task->send_data =3D g_malloc(task->send_data_size); + task->send_data_sent =3D 0; + + if (address_space_read(&address_space_memory, task->payload_gpa, + MEMTXATTRS_UNSPECIFIED, task->send_data, + task->send_data_size) !=3D MEMTX_OK) { + goto out_free; + } + + /* Mark the buffer in-flight. */ + hdr.error_code =3D cpu_to_le64(TDX_VP_GET_QUOTE_IN_FLIGHT); + if (address_space_write(&address_space_memory, buf_gpa, + MEMTXATTRS_UNSPECIFIED, + &hdr, TDX_GET_QUOTE_HDR_SIZE) !=3D MEMTX_OK) { + goto out_free; + } + + task->receive_buf =3D g_malloc0(task->payload_len); + task->receive_buf_received =3D 0; + task->opaque =3D tdx_guest; + + object_ref(tdx_guest); + tdx_generate_quote(task, tdx_guest->qg_sock_addr); + run->tdx.get_quote.ret =3D TDG_VP_VMCALL_SUCCESS; + return; + +out_free: + g_free(task->send_data); + g_free(task); +} + void tdx_handle_get_tdvmcall_info(X86CPU *cpu, struct kvm_run *run) { if (run->tdx.get_tdvmcall_info.leaf !=3D 1) { return; } =20 - run->tdx.get_tdvmcall_info.r11 =3D 0; + run->tdx.get_tdvmcall_info.r11 =3D TDG_VP_VMCALL_SUBFUNC_GET_QUOTE; run->tdx.get_tdvmcall_info.r12 =3D 0; run->tdx.get_tdvmcall_info.r13 =3D 0; run->tdx.get_tdvmcall_info.r14 =3D 0; @@ -1263,6 +1399,37 @@ static void tdx_guest_set_mrownerconfig(Object *obj,= const char *value, Error ** tdx->mrownerconfig =3D g_strdup(value); } =20 +static void tdx_guest_get_qgs(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + TdxGuest *tdx =3D TDX_GUEST(obj); + + if (!tdx->qg_sock_addr) { + error_setg(errp, "quote-generation-socket is not set"); + return; + } + visit_type_SocketAddress(v, name, &tdx->qg_sock_addr, errp); +} + +static void tdx_guest_set_qgs(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + TdxGuest *tdx =3D TDX_GUEST(obj); + SocketAddress *sock =3D NULL; + + if (!visit_type_SocketAddress(v, name, &sock, errp)) { + return; + } + + if (tdx->qg_sock_addr) { + qapi_free_SocketAddress(tdx->qg_sock_addr); + } + + tdx->qg_sock_addr =3D sock; +} + /* tdx guest */ OBJECT_DEFINE_TYPE_WITH_INTERFACES(TdxGuest, tdx_guest, @@ -1294,6 +1461,13 @@ static void tdx_guest_init(Object *obj) object_property_add_str(obj, "mrownerconfig", tdx_guest_get_mrownerconfig, tdx_guest_set_mrownerconfig); + + object_property_add(obj, "quote-generation-socket", "SocketAddress", + tdx_guest_get_qgs, + tdx_guest_set_qgs, + NULL, NULL); + + qemu_mutex_init(&tdx->lock); } =20 static void tdx_guest_finalize(Object *obj) diff --git a/target/i386/kvm/meson.build b/target/i386/kvm/meson.build index 3f44cdedb75..2675bf89027 100644 --- a/target/i386/kvm/meson.build +++ b/target/i386/kvm/meson.build @@ -8,7 +8,7 @@ i386_kvm_ss.add(files( =20 i386_kvm_ss.add(when: 'CONFIG_XEN_EMU', if_true: files('xen-emu.c')) =20 -i386_kvm_ss.add(when: 'CONFIG_TDX', if_true: files('tdx.c'), if_false: fil= es('tdx-stub.c')) +i386_kvm_ss.add(when: 'CONFIG_TDX', if_true: files('tdx.c', 'tdx-quote-gen= erator.c'), if_false: files('tdx-stub.c')) =20 i386_system_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_f= alse: files('hyperv-stub.c')) =20 --=20 2.49.0