From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059675; cv=none; d=zohomail.com; s=zohoarc; b=lQHdwyZxpHCKW4bA+n58U7Ep3P/UM1wyeqBAOFmHp56auoTSnZfA/4NXX3a6SCDMLqGPiDWR8/kW7QarnvjmvGt7RkCymysluGV8m4DtZTlqTyl/Yk8MKQksyIww5O02kaapFIbNPNwDF4kCrFvuZi+VS6VLcdEXAJlZpjzpNqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059675; 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=gUXOLixf54/Phpgl1bLqDDS7TZylxbd8N1kxNtuKv2s=; b=DKi80jR7UZb3vm/qbATz5CF2MtVKYF1saVpLyKATLBLaO0rboJ5IHSx69rlFfb+hsEJFtrsEhOOuXkTOysVipF31Xq8iA7LlsXOezhnrNvhO4KyiklEV5nCRgkNr+rTH5Zvgwh39EmllY3yQci/USVmYafyUy390pt8smFP+Ito= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059675513992.9335187678514; Fri, 4 Oct 2024 09:34:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGC-0005W0-3g; Fri, 04 Oct 2024 12:34:32 -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 1swlG7-0004jR-Ks for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:27 -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 1swlG5-00066Q-Ti for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:27 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527---KYKEBQNUGgaixaPnpcpQ-1; Fri, 04 Oct 2024 12:34:24 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42cb635b108so15828705e9.2 for ; Fri, 04 Oct 2024 09:34:23 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86b4a38bsm19419185e9.39.2024.10.04.09.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059665; 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=gUXOLixf54/Phpgl1bLqDDS7TZylxbd8N1kxNtuKv2s=; b=AcIF0AntI16NzRUjX/eOsh9RppQAv9oRQdqo3HjaHxJro+Eknd7HJcUetMgn8O777GqHLk EzglIrO+LyRcDbzVgrDyOoTWY29ZQGioCPXoxO5XFmg3YVnO9RGBhL3OjYBm2nKW3IPQRu O0QSIRYYKWncXNvr9vUJQtdu8d1SRIg= X-MC-Unique: --KYKEBQNUGgaixaPnpcpQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059662; x=1728664462; 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=gUXOLixf54/Phpgl1bLqDDS7TZylxbd8N1kxNtuKv2s=; b=DvtTT9LPVgjYsOl93qCOuManzDCUcfTkGrhnlzJ/ocDFi94YVkhuahmkJ1kWA/YNDi XacXL9xBBbRxZlo4SpdXEIElBJkCjJRMinFMVmVu2D7wf/yY3+Gmv2YxlCk/291dNuwW Z07zWmmZBY/Fp2ipkPjGHoB6S5oTrkjNq+TcqURyKRm1q8j8JMbXqG0W8LOLRV1BH2oS Zd0UzZDjb5ccHqf9Phzsd6nLuTLjXTqPc9pyKt8UoKacxQnbi9icndv36r4PbnyYxyzh twZlGs5LoWo4N7wOf6IhMYOC/qRebQR9km6BfkQG/4NW3wcyZSPf5DsVSKTGkVXd5Fpe 731Q== X-Gm-Message-State: AOJu0Yz51zlj0SxCAcqLDH3hUgLtwPbOMkq9iCcJCcgJxfGMAbv0V6pJ 4hFBor9txce7/mC81NWiFa95qs2BVGpOZ4VSYveX5fivKpiXSbFswaMjtJAP1flPMoEUpgBPYES 859OYOWZGx/nNQwGzRaIdieO4fsiHN/xNxPAK70MYz9AU2FTkCtn4PRrQBH0rN8r4IKT+LoteLG 9Csw5h2d06UP2c96jhKIFeI8M2Zj2EMJ9rUG4AD/4= X-Received: by 2002:a05:600c:19c6:b0:42f:8515:e47d with SMTP id 5b1f17b1804b1-42f85ab68femr26865725e9.11.1728059662440; Fri, 04 Oct 2024 09:34:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPJd52gdJpiVPDM77fyImR7BVciNpcbGpdeHcj90FBsrO9t6PfIvqSBP0CJH77WRqij9RSng== X-Received: by 2002:a05:600c:19c6:b0:42f:8515:e47d with SMTP id 5b1f17b1804b1-42f85ab68femr26865515e9.11.1728059661948; Fri, 04 Oct 2024 09:34:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Xin Li (Intel)" Subject: [PULL 01/23] target/i386: Delete duplicated macro definition CR4_FRED_MASK Date: Fri, 4 Oct 2024 18:33:53 +0200 Message-ID: <20241004163415.951106-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059677229116600 Content-Type: text/plain; charset="utf-8" From: "Xin Li (Intel)" Macro CR4_FRED_MASK is defined twice, delete one. Signed-off-by: Xin Li (Intel) Link: https://lore.kernel.org/r/20240807081813.735158-2-xin@zytor.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 14edd57a37b..2bf37dd15e0 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -267,12 +267,6 @@ typedef enum X86Seg { #define CR4_FRED_MASK 0 #endif =20 -#ifdef TARGET_X86_64 -#define CR4_FRED_MASK (1ULL << 32) -#else -#define CR4_FRED_MASK 0 -#endif - #define CR4_RESERVED_MASK \ (~(target_ulong)(CR4_VME_MASK | CR4_PVI_MASK | CR4_TSD_MASK \ | CR4_DE_MASK | CR4_PSE_MASK | CR4_PAE_MASK \ --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059693; cv=none; d=zohomail.com; s=zohoarc; b=JCbntskoE/J2mB4J2Uakkk5PM3t8XkYis20ZW7OHBOrk8Lfm3U+zFe4AMOHwfOd4oFR+CW5Msb7FBeao/kuQQBffPvsmrY0QYqRmGp1Fpe8mkCcRXRpEXBV694irl9FIqIKiHh4C7nQC8LyJ3pNgce8TdcYreM1fkY5ItVZT+Vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059693; 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=0DZTXKevYJ6TeDBJAdOHGKQp8DOkIyrthfbjQsPm68c=; b=YGlYDQYRV+bM+yRHQA0uPiUnGxR/i1tEQrUCf11kENoDyY0b/4gVY8YEoUKd6+/+GIh2LyYKqa6QYXYtatmyIo+HaovUdPVJJ5KFeTUie/hOdg8zLdccYwxWSx1o326hmV5hz99VFZBvTNKYXHAQfvcJ9QLutzqcrtnea651lrs= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059693479169.89856710387414; Fri, 4 Oct 2024 09:34:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGC-0005Wm-A2; Fri, 04 Oct 2024 12:34:32 -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 1swlGA-0005RC-UV for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:31 -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 1swlG9-00067G-7h for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:30 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-fdi-kfLJPryeR6Os9uyUEw-1; Fri, 04 Oct 2024 12:34:27 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37cdb213bf9so1326911f8f.2 for ; Fri, 04 Oct 2024 09:34:27 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1691b4c1sm35191f8f.45.2024.10.04.09.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059668; 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=0DZTXKevYJ6TeDBJAdOHGKQp8DOkIyrthfbjQsPm68c=; b=XwCf5lojGTcFNmILh753S83uI/KqOkBXZoZWv++TByTnnzvDoVhVWRaQ0WZVobo+1G465h S9i68SJJOEwrlliX0PWFiLb8a7Wq5VuWIENiIJ9XKp5i3WeaKLQTiHQhznab2q4KOzWWwK JgX9xxeirOuYhwbpwrAXFgstWV+Q4Jc= X-MC-Unique: fdi-kfLJPryeR6Os9uyUEw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059665; x=1728664465; 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=0DZTXKevYJ6TeDBJAdOHGKQp8DOkIyrthfbjQsPm68c=; b=ZlsRU+bK6LMKYnVG6PUemXAh5ocY9B0yBlr0kD1Xpv8CZWDNZHrkjXKk6Pn2rUzFOQ v9+nCY9+iCKGSr4aMM6pH31T12CttNbq374On1I2j/aOsdgVcFf+NHmQ6BoFx8XaEGB0 WCQJClQJh3KDyCXubgv9fmSDwYK9jKAnVpzylN9HzwBPg82bp/2XG8Af2TNFuhkp6JL3 tKx6/ppdDDYCZKKpwSMrG17UABRTqMIwAgR4kgcW/gXGr6EHyhvklGXJw+i8KKaJuup+ gnDtfm0fEa483lJJQJEA7lLD1bEYfBSWY80LbqKZUSaPqJZDrZh8/9XkYX1JD/I3IcPU O8zQ== X-Gm-Message-State: AOJu0YxH45vc/dGnnRTRLAvfkciagDkjG0oDVRuAcib+XrMdziTf7HEx tFbI+4nsu2E5Q6IDrdcEfFpcb0cIPZ5w94CP/pTqFyQSIXgZEEYrh4UhtNNkJFpoVladT5MXKxF F78+BeKzGQDG/TNA3lJQfgarGDgQ2qfQXTZBijoShIv/rOvA4ybk2JRpWto92KZVarjsV7/X7kx eJJplPK8kMDnOgf5eNxxN6aA5Jov9RGH8w7nVSYAM= X-Received: by 2002:a5d:4411:0:b0:374:c4c2:fc23 with SMTP id ffacd0b85a97d-37d0eae97femr2470600f8f.56.1728059665524; Fri, 04 Oct 2024 09:34:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhmU1pcEhazEpV1PzQmh2gleuyBf0/8ZCTdKEXCRHbfcm7xEX+99Czmi/WlkmBEf69wsyNhw== X-Received: by 2002:a5d:4411:0:b0:374:c4c2:fc23 with SMTP id ffacd0b85a97d-37d0eae97femr2470583f8f.56.1728059665020; Fri, 04 Oct 2024 09:34:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Xin Li (Intel)" , Zhao Liu Subject: [PULL 02/23] target/i386: Add VMX control bits for nested FRED support Date: Fri, 4 Oct 2024 18:33:54 +0200 Message-ID: <20241004163415.951106-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059695316116600 Content-Type: text/plain; charset="utf-8" From: "Xin Li (Intel)" Add definitions of 1) VM-exit activate secondary controls bit 2) VM-entry load FRED bit which are required to enable nested FRED. Reviewed-by: Zhao Liu Signed-off-by: Xin Li (Intel) Link: https://lore.kernel.org/r/20240807081813.735158-3-xin@zytor.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 85ef7452c04..31f287cae05 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1435,7 +1435,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "vmx-exit-save-efer", "vmx-exit-load-efer", "vmx-exit-save-preemption-timer", "vmx-exit-clear-bndcfgs", NULL, "vmx-exit-clear-rtit-ctl", NULL, NULL, - NULL, "vmx-exit-load-pkrs", NULL, NULL, + NULL, "vmx-exit-load-pkrs", NULL, "vmx-exit-secondary-ctls", }, .msr =3D { .index =3D MSR_IA32_VMX_TRUE_EXIT_CTLS, @@ -1450,7 +1450,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { NULL, "vmx-entry-ia32e-mode", NULL, NULL, NULL, "vmx-entry-load-perf-global-ctrl", "vmx-entry-load-pat",= "vmx-entry-load-efer", "vmx-entry-load-bndcfgs", NULL, "vmx-entry-load-rtit-ctl", NUL= L, - NULL, NULL, "vmx-entry-load-pkrs", NULL, + NULL, NULL, "vmx-entry-load-pkrs", "vmx-entry-load-fred", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059717; cv=none; d=zohomail.com; s=zohoarc; b=KMoWTakZiE5/Jl0ENQaEh3uBuKfDwd9abzXufySW1kvR4SfRNJbF1aKS+r2TM68odOVpU339TFsewhLg7zfyTd4j3lDqh7cxqQRBzCT9xPHz/aB3DhTcpJYQEjEHy1STwfDLHIZNkcCGUd7snY2gGC3ORMGZsty69SWpkJVSZW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059717; 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=KpzQuUOK0nFh0jcyW4lxqmvDGPCRl433Pr2mfBKjlTo=; b=Js3pmGx4qq09k6hdN2InZblbTweu45J5tF9f0g4FNdDkbj3XRx7ae0RazqBupD5NavqB5XWPBcob/pbK9iQcGQYyMckpWo+8gFXvSYodTGBApM9SPfgHU7ZQJqNYaNkwIMtHjGBL+aWhpQbLFUNZwSAk3N+tP9pZANG12Qw+Ou0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059717670925.224761750906; Fri, 4 Oct 2024 09:35:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGV-0006XZ-Aq; Fri, 04 Oct 2024 12:34:52 -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 1swlGH-0006Lb-2q for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:37 -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 1swlGE-00069L-NT for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:36 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-74TfZIqWPHuGjJ-fL7fNkg-1; Fri, 04 Oct 2024 12:34:29 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb5f6708aso13897115e9.2 for ; Fri, 04 Oct 2024 09:34:29 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89e858d2sm1612165e9.10.2024.10.04.09.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059674; 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=KpzQuUOK0nFh0jcyW4lxqmvDGPCRl433Pr2mfBKjlTo=; b=RQf+srIhuwFBX2cNBtHhUoTEBw4z6h4fQGG+sguo6Ah6eiUdx0775G+kX01SstCVTjV0A1 Q4gjFWam4yLEXmRdVV1kuKVgBFbMfTyDakDKrnVQLqvT9qXoK/n5oxXXxlyfMLFVls36Mr dfZmonVGtrXO666dcmW5kvXDQCbgr1A= X-MC-Unique: 74TfZIqWPHuGjJ-fL7fNkg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059668; x=1728664468; 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=KpzQuUOK0nFh0jcyW4lxqmvDGPCRl433Pr2mfBKjlTo=; b=NlieM9aDXkJRp8uP6LlLi7PAN3fmNX0bCaodntYh5DqwJIHRU5Kyv2aDZkcBU+IWkV ca2Djqtc32gRK9FovoV5PM12tZV4VlooaVEoiX1XRvSJsdXDvFbnWa3gHYGgpQWS57ZR NJJUwZmXYSHNE//Pvd9Wc10kzzzQ7f/d6ZxwXxJo0FZHTwQznQlmI3FMXfWz2IFy6UmP qR518rU7lsaSUkLH7PdG6jXvBJJBeZVztKUInxNUrBy73XLFkYj9gPDl9HRT7gT4Q6pm 8IlxrzxTprRc2wea4ITlYvQpGTaRkclQc7/ShHZxV6DT3L4awpOt9xzQ87Bf4snBHaWW 6RHw== X-Gm-Message-State: AOJu0YxF4h11B9BerSWl+TFnnSQNpP+w4LR50Re+0MoZfSAlmeDXWmJJ Y+yLZTFMpPprXOadYmB/tzUmlSkFwrto1uQhsew4SoU1A2Ilh7ISwNGfwJWrvRwOKSkRYamLzf4 F1nu7YT5pSE6+452zaws5W6VTV5FsgTpjao0aBpLvszVVl3ekl3Y6sXH8pUUiywiSBQWrHZVEmm O85V2qUsMB+6G3U69YQ3hyAMYKUtkRMdsDrhJ3gvE= X-Received: by 2002:a05:600c:4449:b0:426:5dc8:6a63 with SMTP id 5b1f17b1804b1-42f85af408cmr22759045e9.30.1728059668241; Fri, 04 Oct 2024 09:34:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyV7nJ02GF+LaQA/J/pWS1H1TEDw7tflLvWmBOZeNhi6Yyw73yJq1PCLAGlDbnaew3r/0TdQ== X-Received: by 2002:a05:600c:4449:b0:426:5dc8:6a63 with SMTP id 5b1f17b1804b1-42f85af408cmr22758865e9.30.1728059667841; Fri, 04 Oct 2024 09:34:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Lei Wang , Xin Li , "Xin Li (Intel)" Subject: [PULL 03/23] target/i386: Raise the highest index value used for any VMCS encoding Date: Fri, 4 Oct 2024 18:33:55 +0200 Message-ID: <20241004163415.951106-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059719452116600 Content-Type: text/plain; charset="utf-8" From: Lei Wang Because the index value of the VMCS field encoding of FRED injected-event data (one of the newly added VMCS fields for FRED transitions), 0x52, is larger than any existing index value, raise the highest index value used for any VMCS encoding to 0x52. Because the index value of the VMCS field encoding of Secondary VM-exit controls, 0x44, is larger than any existing index value, raise the highest index value used for any VMCS encoding to 0x44. Co-developed-by: Xin Li Signed-off-by: Xin Li Signed-off-by: Lei Wang Signed-off-by: Xin Li (Intel) Link: https://lore.kernel.org/r/20240807081813.735158-4-xin@zytor.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 2bf37dd15e0..9c39384ac0a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1186,6 +1186,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *c= pu, FeatureWord w); #define VMX_VM_EXIT_PT_CONCEAL_PIP 0x01000000 #define VMX_VM_EXIT_CLEAR_IA32_RTIT_CTL 0x02000000 #define VMX_VM_EXIT_LOAD_IA32_PKRS 0x20000000 +#define VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS 0x80000000 =20 #define VMX_VM_ENTRY_LOAD_DEBUG_CONTROLS 0x00000004 #define VMX_VM_ENTRY_IA32E_MODE 0x00000200 diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index c8056ef83d7..27a3d7626cf 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3694,7 +3694,14 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, Featu= reWordArray f) kvm_msr_entry_add(cpu, MSR_IA32_VMX_CR4_FIXED0, CR4_VMXE_MASK); =20 - if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) { + if (f[FEAT_7_1_EAX] & CPUID_7_1_EAX_FRED) { + /* FRED injected-event data (0x2052). */ + kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x52); + } else if (f[FEAT_VMX_EXIT_CTLS] & + VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS) { + /* Secondary VM-exit controls (0x2044). */ + kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x44); + } else if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING= ) { /* TSC multiplier (0x2032). */ kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x32); } else { --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059718; cv=none; d=zohomail.com; s=zohoarc; b=d28/gNlMJQdmHAM2JVrC5R3iSNcfxDVmHGBRix8PHEKGDttyM6mfngtpRRpnM27Ivvi+7fyz1XZ3iVyeG6XVFJZzjsJNossSlzIwM+sJhFrUW+UAPhfz87ypBFYSsR9m/Cdx+MirkP34GRWS9D/KTrz3ywgKE2aHMIX3SXOnc4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059718; 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=mUn5c3pfQStI53Zd5c7QBE8d3u2NmM4zj5U6cf4nThw=; b=VpI6nkE0DCWoTgpalCtcnJZLrg2e9IJURTHRpdGS/SSoaPxU4VnU25DyHoxQwcG/2kJDPUzWq7L9ew+WlRpdjkb8KtlByj2SB6kZiHwezkZLSN/kIrmOsEXBX0ddyP0iIxXtty9qEyQVSu8dBJ6Ma4NjF2w+47Qw0X0DJsxoQg0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172805971830517.606967904733892; Fri, 4 Oct 2024 09:35:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGr-0007Ii-RX; Fri, 04 Oct 2024 12:35:14 -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 1swlGJ-0006QL-1V for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:41 -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 1swlGG-00069Q-Pp for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:38 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-1AHYwE1wMze52jC-k4kiuA-1; Fri, 04 Oct 2024 12:34:32 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37cd23c9226so1457957f8f.0 for ; Fri, 04 Oct 2024 09:34:32 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86b1d672sm19469335e9.28.2024.10.04.09.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059674; 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=mUn5c3pfQStI53Zd5c7QBE8d3u2NmM4zj5U6cf4nThw=; b=WhufGUE0stSbsi2A5O9zPzZl5K2bFMVQCGYSF/XNdo84LtQwFj/ALJSYQG5X19hxfkR5pA p31XiQ0tJ1vad6/Ea8C53UoUyZP2HYY3wCSZ+xjfhEj1iCErRRDJ8NvTSmyZHIiWRUoX2P jwoKKbP6IFX6lrWXMvxtJy91newqXH0= X-MC-Unique: 1AHYwE1wMze52jC-k4kiuA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059671; x=1728664471; 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=mUn5c3pfQStI53Zd5c7QBE8d3u2NmM4zj5U6cf4nThw=; b=mLvjzYXk+moI0cfXVnMYxDHO8tM1oRs+Yc2moHHO6Hcvlo2/nARP+gWLIMgT3ARg8W XnYOvNCYMwppS1axD2HwdYSqWioT/6Sml7zzlJB3pCRadzWFE8aJml+p1OGtuZFChV+j jeNpWyRFfzNnqvFSk3Z+X95c9MixH4MRN803BpIwr9+NdCYST4a/bngvW3ZZEXwhL7dr EmU20d2cYkB0wONPfq0pr9Al6BHVkLgxSV6+4DWsYMWYfYr0wsm20VzHFx9QyncSZ7EZ p2t5S/ommwC3INRuxYoCwxKdV7PXApaPmqII1QhtbxfCXKEHw3S8RohSFJyM+7sZe3rW qABQ== X-Gm-Message-State: AOJu0Yzri1u31J5cFEkPSxp9/iKg1s3/0RPfbbyiQQmFAjtWsLlEe965 c0PplLnGC6JW3f2n2TgQT26npx+E3nzAE0QSwbAFwvtKMU+91ohNw0HJXIU7ZeiVA7oiSmVYD2t eslL6pqZLdifNtK4ATQTCJ4PG4yFsWYmF0Ob1E5EuhhYFl041esjPIEcPNyMMFol5lYf9/QkoHW dLMkpDP4eoHefotFNL4hIacnFvQZMLx2TunhVEM84= X-Received: by 2002:adf:e84c:0:b0:37c:c9bc:1be6 with SMTP id ffacd0b85a97d-37d049f1696mr4894225f8f.16.1728059671213; Fri, 04 Oct 2024 09:34:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6gmi0oaYzGhsHfQThqMQqQ5urlDPyPAZIY9iDoMG5e9M2WeYUlDnvJNfI9f5B2B82gMsC9A== X-Received: by 2002:adf:e84c:0:b0:37c:c9bc:1be6 with SMTP id ffacd0b85a97d-37d049f1696mr4894207f8f.16.1728059670760; Fri, 04 Oct 2024 09:34:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Richard W.M. Jones" Subject: [PULL 04/23] tests/unit: remove block layer code from test-nested-aio-poll Date: Fri, 4 Oct 2024 18:33:56 +0200 Message-ID: <20241004163415.951106-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059719435116600 Content-Type: text/plain; charset="utf-8" GCC is reporting a NULL pointer dereference when compiling aio_wait_kick() with LTO. The issue is that test-nested-aio-poll.c does not call qemu_init_main_loop(= ). It doesn't _need_ to because it never calls AIO_WAIT_WHILE(), but it seems that LTO does not do enough dead-code elimination to catch that. Fortunately aio_wait_kick() is only used in few places, and only in block layer or system emulation code; and this test only needs the core event loop functionality. It does not even need iothreads. So remove everything that calls aio_wait_kick(), which is nice for coverage compared to adding the ca= ll to qemu_init_main_loop(). Reported-by: Richard W.M. Jones Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2434 Signed-off-by: Paolo Bonzini --- tests/unit/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 21d101301bc..d5248ae51de 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -116,7 +116,7 @@ if have_block if host_os !=3D 'windows' tests +=3D { 'test-image-locking': [testblock], - 'test-nested-aio-poll': [testblock], + 'test-nested-aio-poll': [], } endif if config_host_data.get('CONFIG_REPLICATION') --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059733; cv=none; d=zohomail.com; s=zohoarc; b=A/PhJltqAq5IszEFroNGNad9dA0qOPGAgD9bzWpHpG4Qj2ppCOBQTIyOXfQq/zTvNFakVZYNjnVPZMfBczelf48L7zuR/Y8meojW0SXlkNZba8Y9RaqE3dTitnrvB9MhUfKg0nLmHe7fEVqZlCQKDKzVmRvUDkailLFpP9NkKBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059733; 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=PwAi0zbVtrrkRs71yZC6BRcXMXEBnLA8T1zN9S8kLxs=; b=G42xcujQ+auAIQvX03iYY1W55Equsf/tgQiuxnwlStBPF1fcK0BpLuzh3I1IQCknkehl8+LfQpW04y7IFVU3bK3QGGVBQupmq3mXeVCtyDLs70vjk699nsb1Nfvj9ej82aH1Nmt4YX1qOXmI99R3n78JcLE6J83T07rDuIASFXU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059733857906.2493441171009; Fri, 4 Oct 2024 09:35:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGx-0007yO-78; Fri, 04 Oct 2024 12:35:19 -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 1swlGN-0006WH-0n for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:45 -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 1swlGK-0006A6-FG for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:41 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-Ick7QVX5MNe6wZYnYzRxzQ-1; Fri, 04 Oct 2024 12:34:35 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42e611963c2so17700305e9.1 for ; Fri, 04 Oct 2024 09:34:35 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89e8360asm1611325e9.1.2024.10.04.09.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059679; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PwAi0zbVtrrkRs71yZC6BRcXMXEBnLA8T1zN9S8kLxs=; b=T7gPxmNXN9p21AGDMIx0IrrtRVnz0H1f7A3woJ8xdKIaQoHEiZqzi1HB9vOMZZcxQ4siU9 coX9yh8pehFSEhqZFbnlk14bGppcYAptmgCcGhmvxKnPT+uC3g2NuI8s1IlG7NuprcDfK6 pA3HQCEAN6hA0NJZwFbnSzIzBWaz+5o= X-MC-Unique: Ick7QVX5MNe6wZYnYzRxzQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059674; x=1728664474; 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=PwAi0zbVtrrkRs71yZC6BRcXMXEBnLA8T1zN9S8kLxs=; b=G1uYcmamIGS+PY0BG8wNb4vOaNtLGWO1EyuUhH+QZKPWZoWix9+XOBFJh4DRvfr75D Efc7HSqd8HE2o7Bjk/cGQ+NkA5NrYV1xgkI1TJsvNCMwvh3Zg1dSIhddTprfCXGp2gTe kY4J+Vt/tb89iyftuiZXsm57/8lGzUXC8bPdlaUts3KnR2qlvn8tm5fK3RHl4Ad9mH7d u4VnMwIfIoHbrlRNCu35nrO04dwDr5UHSNRq2QG5jKpBnf3SHFD17eVIytqF0uMAkAkd 9PB9ubKI09aghyU33as0AXtixfJgxst9pcKnkciIfN970hQhDxXTZRMgV6cwxHDO5RTZ XvNQ== X-Gm-Message-State: AOJu0Yx0E8HF27NmKMj0wNO1zODWFeSdmEXEWBV68+aifieljLj0nvsr ryxO76jg2XatXjLptq6b+vFJGb4ziHvpaNCyoVBkyiZe7ep52qREOlfplZyoGgsSY+zlr+qh5Ut ZVyhwQXdZsVO46H6I8L651od4PsbGr3CR/V1looIYSSvH3laigldNbfBlpVuigr+F8vJT/wTk/Y SmvBqL4Xmsn+VxqKj7H0cORe81+hdJ7bxvznEQnv4= X-Received: by 2002:a05:600c:1c17:b0:42c:ae76:6cea with SMTP id 5b1f17b1804b1-42f85aab261mr30139565e9.9.1728059674214; Fri, 04 Oct 2024 09:34:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0AhMMEYhIXPAT9qO1lOS42kcGtW02NqXex6DfuEN30Jby/XFPwJXH3dc+RhkjKFJRShMoIA== X-Received: by 2002:a05:600c:1c17:b0:42c:ae76:6cea with SMTP id 5b1f17b1804b1-42f85aab261mr30139325e9.9.1728059673748; Fri, 04 Oct 2024 09:34:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Kamil=20Szcz=C4=99k?= Subject: [PULL 05/23] hw/i386/pc: Add a description for the i8042 property Date: Fri, 4 Oct 2024 18:33:57 +0200 Message-ID: <20241004163415.951106-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059735551116600 From: Kamil Szcz=C4=99k While working on exposing the i8042 property in libvirt I noticed that the property is missing a description. This adds a simple description so that QEMU users don't have to dig in the source code to figure out what this option does. Signed-off-by: Kamil Szcz=C4=99k Link: https://lore.kernel.org/r/15fhXFY6x78KW8P5gw0eKTW8kc17zejrJFxqnOyoBy6= vw4W9rCmgDhoxssWosWFs_dbFtfsyjn9wpPrV3x8Nlzhy8mTJSEnXCr4qyHAhXSw=3D@szczek.= dev Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 80a65d965fb..67a921779ca 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1823,6 +1823,8 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) =20 object_class_property_add_bool(oc, PC_MACHINE_I8042, pc_machine_get_i8042, pc_machine_set_i8042); + object_class_property_set_description(oc, PC_MACHINE_I8042, + "Enable/disable Intel 8042 PS/2 controller emulation"); =20 object_class_property_add_bool(oc, "default-bus-bypass-iommu", pc_machine_get_default_bus_bypass_iommu, --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059733; cv=none; d=zohomail.com; s=zohoarc; b=O2jPaNeIEpNM9kT9YKuCLc7Y+Dl0oXDyBpg3AahvaLOD1HhC1JezEDYqT/TVeUKdOVdfKqkjB/jmfshP+2UJ6+8ElOexTO3s9wyHpQPCl4XSTENyqsD5YqSHzKnmu8gOqulcoqthbR2PobtLrTzPMI6C+t93GwCqosQs4Ap9ABs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059733; 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=4IdWVGMHabiHgz1aIuLkjvE3ZhQKjrK2DgTvqsGpxX0=; b=TmOwoE85npWLSv59cdiOnYkGzqW+HxmPoiC5w1OgQOlGhxrMVwYg4LAXFwdinN6/fh5WMpG5xXkqImevppI2GsbQLAUFu62TVLjwonZ2XXrQuK5g2gcYbeUtQyEWDhrUhOZG5s2K9XMZrwwCrzACXUOk+VH24N4V6Rt3EU8hIWc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059733881369.7986891929546; Fri, 4 Oct 2024 09:35:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGv-0007nr-MY; Fri, 04 Oct 2024 12:35: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 1swlGR-0006XO-EW for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:50 -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 1swlGO-0006AR-MP for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:47 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-R-9gs2gnOC-TS_8CNF4nvQ-1; Fri, 04 Oct 2024 12:34:41 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42cb808e9fcso13979385e9.0 for ; Fri, 04 Oct 2024 09:34:41 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89e8a568sm1580075e9.20.2024.10.04.09.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059683; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4IdWVGMHabiHgz1aIuLkjvE3ZhQKjrK2DgTvqsGpxX0=; b=H9MaVGn3VSe7CQUeOqiTMoHNc2bbPHyk6MbgJHR+fmc8+hjkwZAWblD7XXdiYLXhX7QHpb cg2Oh+gPwbtnmyop02Voxr9gjqdcj+5OLXAR7akyHBGIrHPgJdV10OyQw3Mzof8lzQwSiN SttZNXtotyxRdedTTeSo5Z0Q84Ueadc= X-MC-Unique: R-9gs2gnOC-TS_8CNF4nvQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059680; x=1728664480; 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=4IdWVGMHabiHgz1aIuLkjvE3ZhQKjrK2DgTvqsGpxX0=; b=qaDIrZ829OrMwz+lh5kxZNNr74draJLnNNuWWoiGVgxpxBSAHvjncxUyHEmJozafgN xkU2paGIbvW2On6hRpS6IymvrpDTmVcKtsGOF9Otg89TU6J2oYjiMvBV2BdSogZpRnRs LTAf6hY+Oo5oeUQ8vm1fILDHp+klATB8Z9L8pgnaSWfGe0CD1UqglZ2fc+FsIN8qhQNh hoDVRno/XpCFHNZu10ViTGYTT0GO7NFgkuKDqcQbblZaUWlCGp0fauyPTHfp5BQfJp+z f0/cMg+Lhcw/AzHaOZIJWVrxmggGYP8Aa5cODoceCeCmp2O8R4FeGXkT1MufjPll492W GNgw== X-Gm-Message-State: AOJu0Yz93SeBo/WJnxgZroqkGKAzNVCPcLljhJk9vhUkHkLi1NWsdNlI sHvlQLuqjjjZUZrRL2Z2peGW80godREHJ9dgZpLtqAhu0f/jq4Y0jLJ1VkYEQQRUwGU/eKvo0z9 Z17dSCUnBfovPaupWNshjMBlmzuvwVeejzlj2dSoXDNBc84rLzozfAYEJvhAHACOrpek6DX8VVL kJgwzdfOZlBPs5DhAuUvR+4Pl22/k2UbSNXfDmI84= X-Received: by 2002:a05:600c:3794:b0:42f:8287:c235 with SMTP id 5b1f17b1804b1-42f89c23242mr4351945e9.1.1728059678201; Fri, 04 Oct 2024 09:34:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPMPM4hkqXKlD5Y1qCfRioogHKieMmhkpcmY9Z9Z4due+MEgsGsu6rfnWvuV9IQDYMVYt6GA== X-Received: by 2002:a05:600c:3794:b0:42f:8287:c235 with SMTP id 5b1f17b1804b1-42f89c23242mr4351235e9.1.1728059676357; Fri, 04 Oct 2024 09:34:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha , philmd@linaro.org Subject: [PULL 06/23] kvm/i386: make kvm_filter_msr() and related definitions private to kvm module Date: Fri, 4 Oct 2024 18:33:58 +0200 Message-ID: <20241004163415.951106-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059735479116600 From: Ani Sinha kvm_filer_msr() is only used from i386 kvm module. Make it static so that i= ts easy for developers to understand that its not used anywhere else. Same for QEMURDMSRHandler, QEMUWRMSRHandler and KVMMSRHandlers definitions. CC: philmd@linaro.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240903140045.41167-1-anisinha@redhat.com [Make struct unnamed. - Paolo] Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm_i386.h | 11 ----------- target/i386/kvm/kvm.c | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 34fc60774b8..9de9c0d3038 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -66,17 +66,6 @@ uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address); void kvm_update_msi_routes_all(void *private, bool global, uint32_t index, uint32_t mask); =20 -typedef bool QEMURDMSRHandler(X86CPU *cpu, uint32_t msr, uint64_t *val); -typedef bool QEMUWRMSRHandler(X86CPU *cpu, uint32_t msr, uint64_t val); -typedef struct kvm_msr_handlers { - uint32_t msr; - QEMURDMSRHandler *rdmsr; - QEMUWRMSRHandler *wrmsr; -} KVMMSRHandlers; - -bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr, - QEMUWRMSRHandler *wrmsr); - #endif /* CONFIG_KVM */ =20 void kvm_pc_setup_irq_routing(bool pci_enabled); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 27a3d7626cf..94fdf3cb304 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -92,7 +92,17 @@ * 255 kvm_msr_entry structs */ #define MSR_BUF_SIZE 4096 =20 +typedef bool QEMURDMSRHandler(X86CPU *cpu, uint32_t msr, uint64_t *val); +typedef bool QEMUWRMSRHandler(X86CPU *cpu, uint32_t msr, uint64_t val); +typedef struct { + uint32_t msr; + QEMURDMSRHandler *rdmsr; + QEMUWRMSRHandler *wrmsr; +} KVMMSRHandlers; + static void kvm_init_msrs(X86CPU *cpu); +static bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rd= msr, + QEMUWRMSRHandler *wrmsr); =20 const KVMCapabilityInfo kvm_arch_required_capabilities[] =3D { KVM_CAP_INFO(SET_TSS_ADDR), @@ -5736,7 +5746,7 @@ static bool kvm_install_msr_filters(KVMState *s) return true; } =20 -bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr, +static bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rd= msr, QEMUWRMSRHandler *wrmsr) { int i; --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059865; cv=none; d=zohomail.com; s=zohoarc; b=WWx1Pxdx2M6JBYnIoSncuTVYrUmHE/72MVmUZWGIXyDEXE7N816FpHeskNNQsw7qdeu+VGcfb7jP6p2jcMYkwd6bvg5BU0hF3E0JcxcEuBOKMK0GWdFWQnh/grxuOFD9JytZ5R86zUGc4d28OS6yTfgYuaC/QxLV5wXKxn5RdOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059865; 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=FkJQs4M6TG5A3+cCJfAZ8QZtJwRKwQvtcjCn7qsdE04=; b=a2GbJ2nzocZ8mEBNM5X7gPeHMcCkA5i+cKw0qlP90X/diMVlPHm1sY0fVkHIvrj1Rj+igRcQOCPojweMCMgSPWedh63ZUJzUstkL5hwH10lm4B77iZdOoBjOOo7C/59rpCcnf0xy37T/Y3P0VZ6Q1pm79mZvvk71MSOk5kGXdQQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172805986538029.196804143306053; Fri, 4 Oct 2024 09:37:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlH4-0008O4-1l; Fri, 04 Oct 2024 12:35:27 -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 1swlGS-0006XR-Mm for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:50 -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 1swlGP-0006AV-T2 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:47 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-nUBdTZ3GMsmqx9rmukJwIg-1; Fri, 04 Oct 2024 12:34:42 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37cd08d3678so1011894f8f.1 for ; Fri, 04 Oct 2024 09:34:41 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f77dsm38201f8f.2.2024.10.04.09.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059684; 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=FkJQs4M6TG5A3+cCJfAZ8QZtJwRKwQvtcjCn7qsdE04=; b=Ga3hsORlDE/ubcMfXmaX1abyYEO8xG0QYeBA36Ad9ZPfxAhuo8ci1Eb3J/T6H+zdf594/T +hphgXdtafkpulCvX6uSgt+k6qNf+RE1WX9YwX0KstkVlAjIcbHnVuIbvceHTzn+3S1yAx uSVaHAbH0WeNzTWlIVdhjacEXDwAjOI= X-MC-Unique: nUBdTZ3GMsmqx9rmukJwIg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059680; x=1728664480; 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=FkJQs4M6TG5A3+cCJfAZ8QZtJwRKwQvtcjCn7qsdE04=; b=NjWL5qoBT9K3gzF7ZrbazG3t1p2XA734EVGedLYeMB0M076FKFDJGGIVRoqU8hX6n2 mPYbC1RGZmzSfNt6Khi0IKT9AJ138Ij2zF2E9o+6v1Ou5j6nDa9hMnu0pPMc5QF60EFC d/GoU9ButCZNYeXmvvUcqC6Ygv1FFuqnywfqzuq0vyK8lWTfGvMTNnCMnAnI4x51rdL9 1bIVoR7E1OuDQfXpHT6GvCMUi3Fm5eaArTRz/kmUwlmPbC66KO7c7XIrdp5k7dArBgP4 0TC/fRRhpsbulQ9N67llMGrSFoDEudE8jGH2Dxl+R1WR3W6dlAY9TfgucRVcfT6wMKZN 6+Lg== X-Gm-Message-State: AOJu0YwMkcewLoG6KutQDPGtBAH8+NsamrUFvOVuY2w9s3JQ+ZaU0rDR 2MfrLN/P+Ornjw8/UFH/Uo5/e+p9xwBn4tsFdNQ0VIDYgB28pTmhlCrQx47fUNhpBUIouyjxtdg U4NCJefb+e6HiHnmiBSzYVuZJaluzc0PJnjWaQoxw8KcJ3YGQd/93x3z6jsVHsofrLO4r4QnioX N3jEmJ7eIz7C7d0oBlWKZtdBORaSPHIFqmrSzE744= X-Received: by 2002:a05:6000:c86:b0:37c:ca20:52a with SMTP id ffacd0b85a97d-37d0f6a15cemr2654858f8f.8.1728059680413; Fri, 04 Oct 2024 09:34:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNOZkK/A/UPzmMRaCVQDM+O0jCZjXVDR+H3Fc2MnUQSwMrTl/QEKOOThc8z5dkRCCaLmca1g== X-Received: by 2002:a05:6000:c86:b0:37c:ca20:52a with SMTP id ffacd0b85a97d-37d0f6a15cemr2654833f8f.8.1728059679932; Fri, 04 Oct 2024 09:34:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha Subject: [PULL 07/23] kvm/i386: fix return values of is_host_cpu_intel() Date: Fri, 4 Oct 2024 18:33:59 +0200 Message-ID: <20241004163415.951106-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059866155116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha is_host_cpu_intel() should return TRUE if the host cpu in Intel based, othe= rwise it should return FALSE. Currently, it returns zero (FALSE) when the host CPU is INTEL and non-zero otherwise. Fix the function so that it agrees more wi= th the semantics. Adjust the calling logic accordingly. RAPL needs Intel host = cpus. If the host CPU is not Intel baseed, we should report error. Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240903080004.33746-1-anisinha@redhat.com [While touching the code remove too many spaces from the second part of the error. - Paolo] Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 6 +++--- target/i386/kvm/vmsr_energy.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 94fdf3cb304..fa0be5537fa 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2906,9 +2906,9 @@ static int kvm_msr_energy_thread_init(KVMState *s, Ma= chineState *ms) * 1. Host cpu must be Intel cpu * 2. RAPL must be enabled on the Host */ - if (is_host_cpu_intel()) { - error_report("The RAPL feature can only be enabled on hosts\ - with Intel CPU models"); + if (!is_host_cpu_intel()) { + error_report("The RAPL feature can only be enabled on hosts " + "with Intel CPU models"); ret =3D 1; goto out; } diff --git a/target/i386/kvm/vmsr_energy.c b/target/i386/kvm/vmsr_energy.c index 7e064c5aef3..31508d4e77a 100644 --- a/target/i386/kvm/vmsr_energy.c +++ b/target/i386/kvm/vmsr_energy.c @@ -34,7 +34,7 @@ bool is_host_cpu_intel(void) =20 host_cpu_vendor_fms(vendor, &family, &model, &stepping); =20 - return strcmp(vendor, CPUID_VENDOR_INTEL); + return g_str_equal(vendor, CPUID_VENDOR_INTEL); } =20 int is_rapl_enabled(void) --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059803; cv=none; d=zohomail.com; s=zohoarc; b=l4aoHdX/QgOZtzU3wYQtt6hnuUqNFzTd+fPoG4RtkKvKv92iZ3y51WxpTSquhSdKrkyJlYZA0FxNcNaGhDSQOej8iBU0OmlBflT4Trvqu+lVlP7BY3Ezvr81GvqQipo5vrpfEa6vDr2hjpkorDkA8Lx03pqfeZV4VxB3xFxzLLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059803; 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=VosZkryxUSxT370xwj32ayTSBQobfpGY1xY5tUlU3gw=; b=I3XcrMevq1A/AKkjd5kwz1RLTmLhIRBzAAvdZPIyAEDQXQX01qUhsBCQQBUI4U8ZdSIm8Lrq2xdWt4Vgdhv0gmokiINWCbPuDc96u10rzMGivr+o4DeSygh8k4G0TZ7+z7fLs9GN0b0Z3LgcBA+8dNKxB9wt3CNUJsjrlqP0mvQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059803952475.50507791294035; Fri, 4 Oct 2024 09:36:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGw-0007qs-6m; Fri, 04 Oct 2024 12:35: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 1swlGS-0006XT-Nt for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:50 -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 1swlGR-0006Aj-2v for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:48 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-YKKkqwU5NXi5AJ4fNLf0bg-1; Fri, 04 Oct 2024 12:34:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37cd1fb9497so1690843f8f.1 for ; Fri, 04 Oct 2024 09:34:45 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86a20537sm19461625e9.15.2024.10.04.09.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059686; 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=VosZkryxUSxT370xwj32ayTSBQobfpGY1xY5tUlU3gw=; b=hWQ5WpX6frtRSEyuvimQhoQozNTFDRq84nPQAZdJoKNlwpZAKXCz33/rVl6bfRSRlCLpZ/ aqThmZVDiMS1GKGT/MPK8D7aedzRZOdsfWpPHtd/157FmycGgSsFfOw6qdF5D5bwNihHSj Mkl04oovAtBmm6hUw3Xl9iLAV1W26W8= X-MC-Unique: YKKkqwU5NXi5AJ4fNLf0bg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059683; x=1728664483; 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=VosZkryxUSxT370xwj32ayTSBQobfpGY1xY5tUlU3gw=; b=emg1tQSiKlHmgYUV4vW4TEPlDFZe/Ieglz9M26bGbxU3rypXXXDyB6+vAWoiR/30di n2jEJN5u8bQd+vyGTPZdGnHPXChjFs/ntwEuiTwJwqP2L4167zTLbvT6uGjUw8Us3sNX rbKDQ9QkOQSr4XkXmbpPrAd7/TAhwIeWsSwIlRRolkNsUQzSWO6xJ7yqkpArF2YJBi2Q g+GpbNdnoOew34VVmC17YKz+JZxOxCHacFZqT1/+MWsLxKiSKXmPtMraetl39vZCWNqm TZ3GicL4CQJX1LPTbEaloNy+XYlsyroQdhPakOB3rV0PFLp6hqgatV5+AtCwyuqblM8I MRcA== X-Gm-Message-State: AOJu0Yz7abFnhxGUbeb6flQlQSM74X8WesratHErS0M5lqAfgE1Lqt6O eJapycKiaAxCkyDdD4AWtaRLPhUACEzpUeNBW4yqXJM7gSeAO91yaCL7pFV5kSRW/O6uMXuXGDR LGa/NTI0YhJXODLERdg1xq1z2db+GOHPtjM1+2F1YeGL1+j36SgYwm33dUJrYjNDadwdTWuxQjM gQY4NkdUZn0FGwWUXFGHzu8vfbt3AiFlQUfPouUdc= X-Received: by 2002:adf:e412:0:b0:37c:fee5:bfc7 with SMTP id ffacd0b85a97d-37d049ef115mr5009002f8f.15.1728059683289; Fri, 04 Oct 2024 09:34:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHt/dY/luTgOjLNty7OoWj/vwXkvJeOQCoUWpgNv4LcozFxRBS5GCivVI8McZeiBBDzVYoZLQ== X-Received: by 2002:adf:e412:0:b0:37c:fee5:bfc7 with SMTP id ffacd0b85a97d-37d049ef115mr5008985f8f.15.1728059682812; Fri, 04 Oct 2024 09:34:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha , qemu-trivial@nongnu.org, zhao1.liu@intel.com, armbru@redhat.com Subject: [PULL 08/23] kvm: replace fprintf with error_report()/printf() in kvm_init() Date: Fri, 4 Oct 2024 18:34:00 +0200 Message-ID: <20241004163415.951106-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1728059805910116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha error_report() is more appropriate for error situations. Replace fprintf wi= th error_report() and error_printf() as appropriate. Some improvement in error reporting also happens as a part of this change. For example: From: $ ./qemu-system-x86_64 --accel kvm Could not access KVM kernel module: No such file or directory To: $ ./qemu-system-x86_64 --accel kvm qemu-system-x86_64: --accel kvm: Could not access KVM kernel module: No suc= h file or directory CC: qemu-trivial@nongnu.org CC: zhao1.liu@intel.com CC: armbru@redhat.com Reviewed-by: Zhao Liu Reviewed-by: Markus Armbruster Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240828124539.62672-1-anisinha@redhat.com Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fe4cd721d9b..4c920b7bfe7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2423,7 +2423,7 @@ static int kvm_init(MachineState *ms) QLIST_INIT(&s->kvm_parked_vcpus); s->fd =3D qemu_open_old(s->device ?: "/dev/kvm", O_RDWR); if (s->fd =3D=3D -1) { - fprintf(stderr, "Could not access KVM kernel module: %m\n"); + error_report("Could not access KVM kernel module: %m"); ret =3D -errno; goto err; } @@ -2433,13 +2433,13 @@ static int kvm_init(MachineState *ms) if (ret >=3D 0) { ret =3D -EINVAL; } - fprintf(stderr, "kvm version too old\n"); + error_report("kvm version too old"); goto err; } =20 if (ret > KVM_API_VERSION) { ret =3D -EINVAL; - fprintf(stderr, "kvm version not supported\n"); + error_report("kvm version not supported"); goto err; } =20 @@ -2484,26 +2484,22 @@ static int kvm_init(MachineState *ms) } while (ret =3D=3D -EINTR); =20 if (ret < 0) { - fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret, - strerror(-ret)); + error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret)); =20 #ifdef TARGET_S390X if (ret =3D=3D -EINVAL) { - fprintf(stderr, - "Host kernel setup problem detected. Please verify:\n"= ); - fprintf(stderr, "- for kernels supporting the switch_amode or" - " user_mode parameters, whether\n"); - fprintf(stderr, - " user space is running in primary address space\n"); - fprintf(stderr, - "- for kernels supporting the vm.allocate_pgste sysctl= , " - "whether it is enabled\n"); + error_printf("Host kernel setup problem detected." + " Please verify:\n"); + error_printf("- for kernels supporting the" + " switch_amode or user_mode parameters, whether"); + error_printf(" user space is running in primary address space\= n"); + error_printf("- for kernels supporting the vm.allocate_pgste" + " sysctl, whether it is enabled\n"); } #elif defined(TARGET_PPC) if (ret =3D=3D -EINVAL) { - fprintf(stderr, - "PPC KVM module is not loaded. Try modprobe kvm_%s.\n", - (type =3D=3D 2) ? "pr" : "hv"); + error_printf("PPC KVM module is not loaded. Try modprobe kvm_%= s.\n", + (type =3D=3D 2) ? "pr" : "hv"); } #endif goto err; @@ -2522,9 +2518,9 @@ static int kvm_init(MachineState *ms) nc->name, nc->num, soft_vcpus_limit); =20 if (nc->num > hard_vcpus_limit) { - fprintf(stderr, "Number of %s cpus requested (%d) exceeds " - "the maximum cpus supported by KVM (%d)\n", - nc->name, nc->num, hard_vcpus_limit); + error_report("Number of %s cpus requested (%d) exceeds " + "the maximum cpus supported by KVM (%d)", + nc->name, nc->num, hard_vcpus_limit); exit(1); } } @@ -2538,8 +2534,8 @@ static int kvm_init(MachineState *ms) } if (missing_cap) { ret =3D -EINVAL; - fprintf(stderr, "kvm does not support %s\n%s", - missing_cap->name, upgrade_note); + error_report("kvm does not support %s", missing_cap->name); + error_printf("%s", upgrade_note); goto err; } =20 --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059804; cv=none; d=zohomail.com; s=zohoarc; b=fXP+dAoiL6EZS8bMoNr17qqYtSwL+5c3r9HSiWIEIiCQ67CiUnZrHJJyewoQTvrAYBEZ5CXh3uMb8w4W2OYYXwGlvoD34B6hSgwJar7mwJ05cypqFnLz8FaaE0/lGdAMHgdhROhXxUmYY8owt5pIutLjYyAXTX5AvNY+GoH19X8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059804; 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=R2g4mc95iEC4Fl6ddcqjWYqmR7w+tez1xzg3U9+5sDY=; b=npwc+JCbp78AGnirpTDcZI6r8fTzSzKe3R9JLWW77jxymzD/z9o6JHD/C2l7+0hgs+JWHDAAhvAfa4EqB38QwSPKRcuwe5WdagFQddu6k+t0x+ZYefAeFhuWhMJrBIdB4QpRHVRgx7sqOHJxkDulnrov7fHPTH7CIPoGYaIwzkc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059804065200.80067472643077; Fri, 4 Oct 2024 09:36:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlH5-0008TN-JQ; Fri, 04 Oct 2024 12:35:27 -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 1swlGY-0006mm-Pf for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:58 -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 1swlGV-0006BY-UK for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:54 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-321-0co8HHeFPm6VAlJMQXw-qg-1; Fri, 04 Oct 2024 12:34:50 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42e611963c2so17701425e9.1 for ; Fri, 04 Oct 2024 09:34:48 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d16921aa4sm33780f8f.64.2024.10.04.09.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059691; 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=R2g4mc95iEC4Fl6ddcqjWYqmR7w+tez1xzg3U9+5sDY=; b=DyRhhPtEccfZXmflUQTabBQwMb0kC5rG45QXa8ZIOuhkd6EfK00IrgrWcFW69eku4A1Dg8 lQM48jlyLsgsmBuHwM+/+xSX1b4eTlrpVrBXNSTbZNqS3omjx6MCRXXkFW+TluVAy0rjt6 cMVLM1KBcOe6YSzmHRc0t1bMs/Swnfk= X-MC-Unique: 0co8HHeFPm6VAlJMQXw-qg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059687; x=1728664487; 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=R2g4mc95iEC4Fl6ddcqjWYqmR7w+tez1xzg3U9+5sDY=; b=Guy9vXku0y8tK2Jgq0vJq8bJ4kzY91GPak9r98+UVo0EyoT+H4J/JxaSRv6oceucFf 618u61Xfp3gqeH4H7xmWFf9L8YYbWJDNUPNWuubiQaEbK0QHB6BCTd487Y/eNb/QPo5m UIzDqGfstPv3V22OFlpn6Fd+g+rBhYwqNDJLSYlZ3lVqKnyYDPUTmB6KHUcbXe7qe00d h+UExqf0aq8uABI+BhOta4ZoB5aFnwUPO9e9p2zSY47ZlsmdBPdYeV9dXYGximqpfo7U G3MlJsod9npXrT5K77mIXbHuEZ6U8lM1DpHZlAE2OemFG8e1AJBrLoA6LSyBKAlPGJGk pWRg== X-Gm-Message-State: AOJu0YyrU3k1p56Khou0aPdV2KIGvCgr7HYbV7MrSAaCFR1i4c7kzXf0 IRHdIGEWMgdqoyz/l2Iry+lhJXNltagOtef4+ZNDhIIVaUex+VvmfRrFzg2gSuWbUbOxjwEh4OT jlyH8wHEvF4ORJ44tDeMB/65K11AHT4RlEi8B8KTi2XbXLgjYBeQPlRpmKsNu5+eex9494sBCjL a6U0ErPJI0XIpK/HvQRfAOpJ0FAIkB+HSVlzigozs= X-Received: by 2002:a5d:6649:0:b0:377:6073:48df with SMTP id ffacd0b85a97d-37d0eaea921mr2061381f8f.58.1728059687051; Fri, 04 Oct 2024 09:34:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF67s4D1Ii/IMMe2GAX9UH7hLrSGGxilQetKOGJqXYtO+ayn0lNPLARd66ttOkIMIvzia1XzQ== X-Received: by 2002:a5d:6649:0:b0:377:6073:48df with SMTP id ffacd0b85a97d-37d0eaea921mr2061365f8f.58.1728059686503; Fri, 04 Oct 2024 09:34:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha Subject: [PULL 09/23] kvm/i386: refactor kvm_arch_init and split it into smaller functions Date: Fri, 4 Oct 2024 18:34:01 +0200 Message-ID: <20241004163415.951106-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059805991116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha kvm_arch_init() enables a lot of vm capabilities. Refactor them into separa= te smaller functions. Energy MSR related operations also moved to its own function. There should be no functional impact. Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240903124143.39345-2-anisinha@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 327 ++++++++++++++++++++++++++---------------- 1 file changed, 201 insertions(+), 126 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index fa0be5537fa..64ef2db9238 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3005,10 +3005,185 @@ int kvm_arch_get_default_type(MachineState *ms) return 0; } =20 +static int kvm_vm_enable_exception_payload(KVMState *s) +{ + int ret =3D 0; + has_exception_payload =3D kvm_check_extension(s, KVM_CAP_EXCEPTION_PAY= LOAD); + if (has_exception_payload) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_EXCEPTION_PAYLOAD, 0, true); + if (ret < 0) { + error_report("kvm: Failed to enable exception payload cap: %s", + strerror(-ret)); + } + } + + return ret; +} + +static int kvm_vm_enable_triple_fault_event(KVMState *s) +{ + int ret =3D 0; + has_triple_fault_event =3D \ + kvm_check_extension(s, + KVM_CAP_X86_TRIPLE_FAULT_EVENT); + if (has_triple_fault_event) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_TRIPLE_FAULT_EVENT, 0, tr= ue); + if (ret < 0) { + error_report("kvm: Failed to enable triple fault event cap: %s= ", + strerror(-ret)); + } + } + return ret; +} + +static int kvm_vm_set_identity_map_addr(KVMState *s, uint64_t *identity_ba= se) +{ + /* + * On older Intel CPUs, KVM uses vm86 mode to emulate 16-bit code dire= ctly. + * In order to use vm86 mode, an EPT identity map and a TSS are neede= d. + * Since these must be part of guest physical memory, we need to alloc= ate + * them, both by setting their start addresses in the kernel and by + * creating a corresponding e820 entry. We need 4 pages before the BIO= S, + * so this value allows up to 16M BIOSes. + */ + *identity_base =3D 0xfeffc000; + return kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, identity_base); +} + +static int kvm_vm_set_nr_mmu_pages(KVMState *s) +{ + uint64_t shadow_mem; + int ret =3D 0; + shadow_mem =3D object_property_get_int(OBJECT(s), + "kvm-shadow-mem", + &error_abort); + if (shadow_mem !=3D -1) { + shadow_mem /=3D 4096; + ret =3D kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem); + } + return ret; +} + +static int kvm_vm_set_tss_addr(KVMState *s, uint64_t identity_base) +{ + /* Set TSS base one page after EPT identity map. */ + return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base); +} + +static int kvm_vm_enable_disable_exits(KVMState *s) +{ + int disable_exits =3D kvm_check_extension(s, KVM_CAP_X86_DISABLE_EXITS= ); +/* Work around for kernel header with a typo. TODO: fix header and drop. */ +#if defined(KVM_X86_DISABLE_EXITS_HTL) && !defined(KVM_X86_DISABLE_EXITS_H= LT) +#define KVM_X86_DISABLE_EXITS_HLT KVM_X86_DISABLE_EXITS_HTL +#endif + if (disable_exits) { + disable_exits &=3D (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE | + KVM_X86_DISABLE_EXITS_CSTATE); + } + + return kvm_vm_enable_cap(s, KVM_CAP_X86_DISABLE_EXITS, 0, + disable_exits); +} + +static int kvm_vm_enable_bus_lock_exit(KVMState *s) +{ + int ret =3D 0; + ret =3D kvm_check_extension(s, KVM_CAP_X86_BUS_LOCK_EXIT); + if (!(ret & KVM_BUS_LOCK_DETECTION_EXIT)) { + error_report("kvm: bus lock detection unsupported"); + return -ENOTSUP; + } + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_BUS_LOCK_EXIT, 0, + KVM_BUS_LOCK_DETECTION_EXIT); + if (ret < 0) { + error_report("kvm: Failed to enable bus lock detection cap: %s", + strerror(-ret)); + } + + return ret; +} + +static int kvm_vm_enable_notify_vmexit(KVMState *s) +{ + int ret =3D 0; + if (s->notify_vmexit !=3D NOTIFY_VMEXIT_OPTION_DISABLE) { + uint64_t notify_window_flags =3D + ((uint64_t)s->notify_window << 32) | + KVM_X86_NOTIFY_VMEXIT_ENABLED | + KVM_X86_NOTIFY_VMEXIT_USER; + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_NOTIFY_VMEXIT, 0, + notify_window_flags); + if (ret < 0) { + error_report("kvm: Failed to enable notify vmexit cap: %s", + strerror(-ret)); + } + } + return ret; +} + +static int kvm_vm_enable_userspace_msr(KVMState *s) +{ + int ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_USER_SPACE_MSR, 0, + KVM_MSR_EXIT_REASON_FILTER); + if (ret < 0) { + error_report("Could not enable user space MSRs: %s", + strerror(-ret)); + exit(1); + } + + if (!kvm_filter_msr(s, MSR_CORE_THREAD_COUNT, + kvm_rdmsr_core_thread_count, NULL)) { + error_report("Could not install MSR_CORE_THREAD_COUNT handler!"); + exit(1); + } + + return 0; +} + +static void kvm_vm_enable_energy_msrs(KVMState *s) +{ + bool r; + if (s->msr_energy.enable =3D=3D true) { + r =3D kvm_filter_msr(s, MSR_RAPL_POWER_UNIT, + kvm_rdmsr_rapl_power_unit, NULL); + if (!r) { + error_report("Could not install MSR_RAPL_POWER_UNIT \ + handler"); + exit(1); + } + + r =3D kvm_filter_msr(s, MSR_PKG_POWER_LIMIT, + kvm_rdmsr_pkg_power_limit, NULL); + if (!r) { + error_report("Could not install MSR_PKG_POWER_LIMIT \ + handler"); + exit(1); + } + + r =3D kvm_filter_msr(s, MSR_PKG_POWER_INFO, + kvm_rdmsr_pkg_power_info, NULL); + if (!r) { + error_report("Could not install MSR_PKG_POWER_INFO \ + handler"); + exit(1); + } + r =3D kvm_filter_msr(s, MSR_PKG_ENERGY_STATUS, + kvm_rdmsr_pkg_energy_status, NULL); + if (!r) { + error_report("Could not install MSR_PKG_ENERGY_STATUS \ + handler"); + exit(1); + } + } + return; +} + int kvm_arch_init(MachineState *ms, KVMState *s) { uint64_t identity_base =3D 0xfffbc000; - uint64_t shadow_mem; int ret; struct utsname utsname; Error *local_err =3D NULL; @@ -3038,24 +3213,14 @@ int kvm_arch_init(MachineState *ms, KVMState *s) =20 hv_vpindex_settable =3D kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX= ); =20 - has_exception_payload =3D kvm_check_extension(s, KVM_CAP_EXCEPTION_PAY= LOAD); - if (has_exception_payload) { - ret =3D kvm_vm_enable_cap(s, KVM_CAP_EXCEPTION_PAYLOAD, 0, true); - if (ret < 0) { - error_report("kvm: Failed to enable exception payload cap: %s", - strerror(-ret)); - return ret; - } + ret =3D kvm_vm_enable_exception_payload(s); + if (ret < 0) { + return ret; } =20 - has_triple_fault_event =3D kvm_check_extension(s, KVM_CAP_X86_TRIPLE_F= AULT_EVENT); - if (has_triple_fault_event) { - ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_TRIPLE_FAULT_EVENT, 0, tr= ue); - if (ret < 0) { - error_report("kvm: Failed to enable triple fault event cap: %s= ", - strerror(-ret)); - return ret; - } + ret =3D kvm_vm_enable_triple_fault_event(s); + if (ret < 0) { + return ret; } =20 if (s->xen_version) { @@ -3086,22 +3251,12 @@ int kvm_arch_init(MachineState *ms, KVMState *s) uname(&utsname); lm_capable_kernel =3D strcmp(utsname.machine, "x86_64") =3D=3D 0; =20 - /* - * On older Intel CPUs, KVM uses vm86 mode to emulate 16-bit code dire= ctly. - * In order to use vm86 mode, an EPT identity map and a TSS are neede= d. - * Since these must be part of guest physical memory, we need to alloc= ate - * them, both by setting their start addresses in the kernel and by - * creating a corresponding e820 entry. We need 4 pages before the BIO= S, - * so this value allows up to 16M BIOSes. - */ - identity_base =3D 0xfeffc000; - ret =3D kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &identity_base); + ret =3D kvm_vm_set_identity_map_addr(s, &identity_base); if (ret < 0) { return ret; } =20 - /* Set TSS base one page after EPT identity map. */ - ret =3D kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base + 0x1000); + ret =3D kvm_vm_set_tss_addr(s, identity_base + 0x1000); if (ret < 0) { return ret; } @@ -3109,13 +3264,9 @@ int kvm_arch_init(MachineState *ms, KVMState *s) /* Tell fw_cfg to notify the BIOS to reserve the range. */ e820_add_entry(identity_base, 0x4000, E820_RESERVED); =20 - shadow_mem =3D object_property_get_int(OBJECT(s), "kvm-shadow-mem", &e= rror_abort); - if (shadow_mem !=3D -1) { - shadow_mem /=3D 4096; - ret =3D kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem); - if (ret < 0) { - return ret; - } + ret =3D kvm_vm_set_nr_mmu_pages(s); + if (ret < 0) { + return ret; } =20 if (kvm_check_extension(s, KVM_CAP_X86_SMM) && @@ -3126,20 +3277,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } =20 if (enable_cpu_pm) { - int disable_exits =3D kvm_check_extension(s, KVM_CAP_X86_DISABLE_E= XITS); -/* Work around for kernel header with a typo. TODO: fix header and drop. */ -#if defined(KVM_X86_DISABLE_EXITS_HTL) && !defined(KVM_X86_DISABLE_EXITS_H= LT) -#define KVM_X86_DISABLE_EXITS_HLT KVM_X86_DISABLE_EXITS_HTL -#endif - if (disable_exits) { - disable_exits &=3D (KVM_X86_DISABLE_EXITS_MWAIT | - KVM_X86_DISABLE_EXITS_HLT | - KVM_X86_DISABLE_EXITS_PAUSE | - KVM_X86_DISABLE_EXITS_CSTATE); - } - - ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_DISABLE_EXITS, 0, - disable_exits); + ret =3D kvm_vm_enable_disable_exits(s); if (ret < 0) { error_report("kvm: guest stopping CPU not supported: %s", strerror(-ret)); @@ -3150,16 +3288,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s) X86MachineState *x86ms =3D X86_MACHINE(ms); =20 if (x86ms->bus_lock_ratelimit > 0) { - ret =3D kvm_check_extension(s, KVM_CAP_X86_BUS_LOCK_EXIT); - if (!(ret & KVM_BUS_LOCK_DETECTION_EXIT)) { - error_report("kvm: bus lock detection unsupported"); - return -ENOTSUP; - } - ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_BUS_LOCK_EXIT, 0, - KVM_BUS_LOCK_DETECTION_EXIT); + ret =3D kvm_vm_enable_bus_lock_exit(s); if (ret < 0) { - error_report("kvm: Failed to enable bus lock detection cap= : %s", - strerror(-ret)); return ret; } ratelimit_init(&bus_lock_ratelimit_ctrl); @@ -3168,80 +3298,25 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } =20 - if (s->notify_vmexit !=3D NOTIFY_VMEXIT_OPTION_DISABLE && - kvm_check_extension(s, KVM_CAP_X86_NOTIFY_VMEXIT)) { - uint64_t notify_window_flags =3D - ((uint64_t)s->notify_window << 32) | - KVM_X86_NOTIFY_VMEXIT_ENABLED | - KVM_X86_NOTIFY_VMEXIT_USER; - ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_NOTIFY_VMEXIT, 0, - notify_window_flags); - if (ret < 0) { - error_report("kvm: Failed to enable notify vmexit cap: %s", - strerror(-ret)); - return ret; - } - } - if (kvm_vm_check_extension(s, KVM_CAP_X86_USER_SPACE_MSR)) { - bool r; - - ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_USER_SPACE_MSR, 0, - KVM_MSR_EXIT_REASON_FILTER); - if (ret) { - error_report("Could not enable user space MSRs: %s", - strerror(-ret)); - exit(1); + if (kvm_check_extension(s, KVM_CAP_X86_NOTIFY_VMEXIT)) { + ret =3D kvm_vm_enable_notify_vmexit(s); + if (ret < 0) { + return ret; } + } =20 - r =3D kvm_filter_msr(s, MSR_CORE_THREAD_COUNT, - kvm_rdmsr_core_thread_count, NULL); - if (!r) { - error_report("Could not install MSR_CORE_THREAD_COUNT handler:= %s", - strerror(-ret)); - exit(1); + if (kvm_vm_check_extension(s, KVM_CAP_X86_USER_SPACE_MSR)) { + ret =3D kvm_vm_enable_userspace_msr(s); + if (ret < 0) { + return ret; } =20 if (s->msr_energy.enable =3D=3D true) { - r =3D kvm_filter_msr(s, MSR_RAPL_POWER_UNIT, - kvm_rdmsr_rapl_power_unit, NULL); - if (!r) { - error_report("Could not install MSR_RAPL_POWER_UNIT \ - handler: %s", - strerror(-ret)); + kvm_vm_enable_energy_msrs(s); + if (kvm_msr_energy_thread_init(s, ms)) { + error_report("kvm : error RAPL feature requirement not met= "); exit(1); } - - r =3D kvm_filter_msr(s, MSR_PKG_POWER_LIMIT, - kvm_rdmsr_pkg_power_limit, NULL); - if (!r) { - error_report("Could not install MSR_PKG_POWER_LIMIT \ - handler: %s", - strerror(-ret)); - exit(1); - } - - r =3D kvm_filter_msr(s, MSR_PKG_POWER_INFO, - kvm_rdmsr_pkg_power_info, NULL); - if (!r) { - error_report("Could not install MSR_PKG_POWER_INFO \ - handler: %s", - strerror(-ret)); - exit(1); - } - r =3D kvm_filter_msr(s, MSR_PKG_ENERGY_STATUS, - kvm_rdmsr_pkg_energy_status, NULL); - if (!r) { - error_report("Could not install MSR_PKG_ENERGY_STATUS \ - handler: %s", - strerror(-ret)); - exit(1); - } - r =3D kvm_msr_energy_thread_init(s, ms); - if (r) { - error_report("kvm : error RAPL feature requirement not mee= t"); - exit(1); - } - } } =20 --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059848; cv=none; d=zohomail.com; s=zohoarc; b=geCDoHXtOeOx7CavPRwKV8zwa4BXlEu1UKbwfr284xrnIIlHZuZBXT7K73VkodlIz+nGPIhCqWT86esaSNWtZtXhNaXI2lkqaNgR0bzgWkWCzfyb5qJynmQLF91s23ddpOVmeF0fWfHH/GS6jLoR97HeSAY1puGaeMr4lXA8ReA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059848; 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=IxyQuyi8N7jciKzaMKuNNPCxNDYD7MTkwKRlfXHgIsE=; b=Ut5/h4s0u/KnYH1FiRLmEU6l+SKt4phzQvwaTl94Kn3sCcaupPHUyQDG5D3LUtCaAIuqkosARKaSTosQO9VNnAbPM5aGL3r83021deRGTSDFCiqUTcWMWwcDLuOtqR8aPijMcyfw9gJ8XV9TtSCw0sTvs2S4iH3JD8POyicCnPY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172805984811784.64415082397; Fri, 4 Oct 2024 09:37:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlHE-0000n2-K9; Fri, 04 Oct 2024 12:35: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 1swlGa-0006mv-Ex for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:59 -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 1swlGY-0006Bg-Q9 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:56 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5-5INQv13uP7eKcXw1wRS8EA-1; Fri, 04 Oct 2024 12:34:51 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42cb236ad4aso13063635e9.3 for ; Fri, 04 Oct 2024 09:34:51 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f3b1sm37844f8f.14.2024.10.04.09.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059693; 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=IxyQuyi8N7jciKzaMKuNNPCxNDYD7MTkwKRlfXHgIsE=; b=dYCB7+jlc3aeDprBt4vc+ZmQAvogKgfkz9MNe7EUdiRZZ56Tgk0DqNiz5ClbuGlGAQayVY jz1ZAbk5V4HcW549xnlpAchNcgcayND0WZXIAQeDIj1qI/xpvKvxXpYa6EocMpau+jQ4X8 W+Lfvby+Vi7GnfXRcHC0Ky17f8EHs30= X-MC-Unique: 5INQv13uP7eKcXw1wRS8EA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059690; x=1728664490; 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=IxyQuyi8N7jciKzaMKuNNPCxNDYD7MTkwKRlfXHgIsE=; b=PidLhJzv5RVz5OIsruCiL+eAXKq01Mal8dM4Rj2+meG1EwES44qJC7svKKFY2cEXiP hJQwe2dcUFX4X55P51xu6TsBBBLJEnbZGYENaavvw5RbQqscALP4fZaOTW/onv+M+gR4 URPsIWvbzOSgFAvJapukgr8wayfcgWz6EogqcwhzzeHdJ92MAllBH1mGeZ1zEXrV4ApK Um6J9lgb8yDYf7ZsJEZQ0QLoxwavMn99AFkhP2bCAPUXSQQrxCSCuOAXWJfvz3EA0nRi edpvOuFuEBBZJm4wILLS7MmI1hd9LA7mwFov+3zDpj3HHBPQyc78eFESLL6BZfAEaZfJ EnEg== X-Gm-Message-State: AOJu0YylP79WLeg0w8rZXdCG1Qyk7ozZAsKxDiGdqNSaijrJqEnL7G+2 Si45h+AuNlo6GHoqL+dGAjg0SKMdXkFtLOdiYWZIGOX2AY79jvrfM06WeyB3Ew1Zyw3negRXo4c AweRXAKyFLD8UvE8sKk4UnhnepuvMEihFxZly3/h53yJbr/2DFV0gBvcSpM5dVC8AoyMBgXacZ6 y41MKbQN0itS88gRr7ZoadhbLuWMs2mcOLGHQofgE= X-Received: by 2002:a05:600c:350c:b0:42f:4f6:f8f3 with SMTP id 5b1f17b1804b1-42f85aa3a92mr22609325e9.7.1728059689787; Fri, 04 Oct 2024 09:34:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvufESLsI8uopANpwm26nJMqI24XmFRK0/zowBzanzjJvDJcRgIzaDSXoJBgJ2XsGEMaK26Q== X-Received: by 2002:a05:600c:350c:b0:42f:4f6:f8f3 with SMTP id 5b1f17b1804b1-42f85aa3a92mr22609125e9.7.1728059689284; Fri, 04 Oct 2024 09:34:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha Subject: [PULL 10/23] kvm/i386: replace identity_base variable with a constant Date: Fri, 4 Oct 2024 18:34:02 +0200 Message-ID: <20241004163415.951106-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059850139116600 Content-Type: text/plain; charset="utf-8" identity_base variable is first initialzied to address 0xfffbc000 and then kvm_vm_set_identity_map_addr() overrides this value to address 0xfeffc000. The initial address to which the variable was initialized was never used. C= lean everything up, placing 0xfeffc000 in a preprocessor constant. Reported-by: Ani Sinha Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 64ef2db9238..7a1f2bda767 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -81,6 +81,16 @@ do { } while (0) #endif =20 +/* + * On older Intel CPUs, KVM uses vm86 mode to emulate 16-bit code directly. + * In order to use vm86 mode, an EPT identity map and a TSS are needed. + * Since these must be part of guest physical memory, we need to allocate + * them, both by setting their start addresses in the kernel and by + * creating a corresponding e820 entry. We need 4 pages before the BIOS, + * so this value allows up to 16M BIOSes. + */ +#define KVM_IDENTITY_BASE 0xfeffc000 + /* From arch/x86/kvm/lapic.h */ #define KVM_APIC_BUS_CYCLE_NS 1 #define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) @@ -3036,18 +3046,9 @@ static int kvm_vm_enable_triple_fault_event(KVMState= *s) return ret; } =20 -static int kvm_vm_set_identity_map_addr(KVMState *s, uint64_t *identity_ba= se) +static int kvm_vm_set_identity_map_addr(KVMState *s, uint64_t identity_bas= e) { - /* - * On older Intel CPUs, KVM uses vm86 mode to emulate 16-bit code dire= ctly. - * In order to use vm86 mode, an EPT identity map and a TSS are neede= d. - * Since these must be part of guest physical memory, we need to alloc= ate - * them, both by setting their start addresses in the kernel and by - * creating a corresponding e820 entry. We need 4 pages before the BIO= S, - * so this value allows up to 16M BIOSes. - */ - *identity_base =3D 0xfeffc000; - return kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, identity_base); + return kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &identity_base); } =20 static int kvm_vm_set_nr_mmu_pages(KVMState *s) @@ -3064,10 +3065,9 @@ static int kvm_vm_set_nr_mmu_pages(KVMState *s) return ret; } =20 -static int kvm_vm_set_tss_addr(KVMState *s, uint64_t identity_base) +static int kvm_vm_set_tss_addr(KVMState *s, uint64_t tss_base) { - /* Set TSS base one page after EPT identity map. */ - return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base); + return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, tss_base); } =20 static int kvm_vm_enable_disable_exits(KVMState *s) @@ -3183,7 +3183,6 @@ static void kvm_vm_enable_energy_msrs(KVMState *s) =20 int kvm_arch_init(MachineState *ms, KVMState *s) { - uint64_t identity_base =3D 0xfffbc000; int ret; struct utsname utsname; Error *local_err =3D NULL; @@ -3251,18 +3250,19 @@ int kvm_arch_init(MachineState *ms, KVMState *s) uname(&utsname); lm_capable_kernel =3D strcmp(utsname.machine, "x86_64") =3D=3D 0; =20 - ret =3D kvm_vm_set_identity_map_addr(s, &identity_base); + ret =3D kvm_vm_set_identity_map_addr(s, KVM_IDENTITY_BASE); if (ret < 0) { return ret; } =20 - ret =3D kvm_vm_set_tss_addr(s, identity_base + 0x1000); + /* Set TSS base one page after EPT identity map. */ + ret =3D kvm_vm_set_tss_addr(s, KVM_IDENTITY_BASE + 0x1000); if (ret < 0) { return ret; } =20 /* Tell fw_cfg to notify the BIOS to reserve the range. */ - e820_add_entry(identity_base, 0x4000, E820_RESERVED); + e820_add_entry(KVM_IDENTITY_BASE, 0x4000, E820_RESERVED); =20 ret =3D kvm_vm_set_nr_mmu_pages(s); if (ret < 0) { --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060130; cv=none; d=zohomail.com; s=zohoarc; b=O0/qGBbIGYt+5YFKbmsJoEBSM3ZHOzwaz7weVrkzh4ODMQh2Tj0q1MK2fXT+glVqvDcdKTir57CF0KLii8gR6smUtf2bd3HAGxHzr6UaIJKLfEVzsN5kIQJSkh5fU8ZKDTjd9fysOJDZQ1pUKmeLJCT0dM26XH1W7pmopvDtFH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060130; 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=ggDZoeB06EyPk6F7B4bvzLC8eI1WG/pc242INantOA0=; b=EAd1DBiHDmnaRgiMG6M0lvDJ+3hZzKuYoFbfA8Hdm7kZj60a/Tha0JBG3SqzHL/eTr3iWMdYXLVHr4umTyWYPHFwIXW4bdBrQVpLmFaQImvKraEtlJh78onyABX6PakzFf4bnYDii+zoyJ/JA4NtNVHor18yIzXMj3LGM6ZnYas= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060130575849.9263673806156; Fri, 4 Oct 2024 09:42:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlIn-0002iq-Cu; Fri, 04 Oct 2024 12:37: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 1swlGe-0006r3-AN for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:02 -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 1swlGa-0006Bx-57 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:57 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-xtaQa8NdP0GOFNUsJRTFag-1; Fri, 04 Oct 2024 12:34:54 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42ca8037d9aso14215905e9.3 for ; Fri, 04 Oct 2024 09:34:54 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86b4a38bsm19428535e9.39.2024.10.04.09.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059695; 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=ggDZoeB06EyPk6F7B4bvzLC8eI1WG/pc242INantOA0=; b=GL2aTVvzmu3aXr2lkR9oGwZYOdu5CUUANvMx4GMlRyha+B95oK1F6AsK2UxsedKKZTb2uU IqfxmAWGdvZQPU1GMKCn2npzBA7PqbLfTyUppcp31k2M6gIBri0zhFL7qmUSohUEhZimgr w5Tp5k4JSXlK736NcNciOmqulJez2r0= X-MC-Unique: xtaQa8NdP0GOFNUsJRTFag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059692; x=1728664492; 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=ggDZoeB06EyPk6F7B4bvzLC8eI1WG/pc242INantOA0=; b=I2eS4qT/ZjOKWEe0vl8rAD+iu27dF3YrZMd/rPgktZdHeCO6Zk13Zk/ibmWmmtA3BJ h0XSpuqiu1597/zsSYWCI55xX+fbM36LDR91ScODhIsKWEOjnALO033AbU7/LLO0YDDv 2kyycFx8uuAbsTxMKnwQXwE/6vtd5xB3xm0Q+D/lH3g4TN5u99xANUQYIX4Ua2LxY5p/ iqxkCKo0sRJno1W02LS1h4WlB3T8YGdbEL8XjitCBA4enCh0OGuUw2//Vy/UEbMGyAGD vsu66UX4XDWCcvPZ8zSboJug6krknCN0GRgj9nt39i0TK4UmejRneJFj9Mz5CDL15AeU YPGQ== X-Gm-Message-State: AOJu0Yw58diqM5nnGtJzOOFqcjFRrZ6uZrp5IZjwf0hhKlIIM/YPRkjg 0uxb9x49QrumsvYddlBnEBpzc4cu98300KYmkj4z9TsaW0pj6L0aHM7gY7HFeV23piGJEhCnjM0 VRbUACox6rCJnVKXh4+xEYG6k4yEG/dJKZHZoz5tDhi9xS0rFVTzKZj6o59eQx4Trste8Lfu8VR v6cA5l3/ALUQjBXJ3Hnu731p4N/SteBpdF06cdwLs= X-Received: by 2002:a05:600c:1ca5:b0:42c:cd88:d0f7 with SMTP id 5b1f17b1804b1-42f85ab4830mr24588705e9.10.1728059692429; Fri, 04 Oct 2024 09:34:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECHg3vsdUjUEJJbqmvmUEZaThBhJBapO/NtQiLSmiqlIOEFPxe37fO36XfDRJJGmmr4yMPeQ== X-Received: by 2002:a05:600c:1ca5:b0:42c:cd88:d0f7 with SMTP id 5b1f17b1804b1-42f85ab4830mr24588505e9.10.1728059692048; Fri, 04 Oct 2024 09:34:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha , pbonzini@redhat.com, zhao1.liu@intel.com Subject: [PULL 11/23] kvm: refactor core virtual machine creation into its own function Date: Fri, 4 Oct 2024 18:34:03 +0200 Message-ID: <20241004163415.951106-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060131704116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha Refactoring the core logic around KVM_CREATE_VM into its own separate funct= ion so that it can be called from other functions in subsequent patches. There = is no functional change in this patch. CC: pbonzini@redhat.com CC: zhao1.liu@intel.com Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240808113838.1697366-1-anisinha@redhat.com Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 89 ++++++++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4c920b7bfe7..e06cf3a4157 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2381,6 +2381,60 @@ uint32_t kvm_dirty_ring_size(void) return kvm_state->kvm_dirty_ring_size; } =20 +static int do_kvm_create_vm(MachineState *ms, int type) +{ + KVMState *s; + int ret; + + s =3D KVM_STATE(ms->accelerator); + + do { + ret =3D kvm_ioctl(s, KVM_CREATE_VM, type); + } while (ret =3D=3D -EINTR); + + if (ret < 0) { + error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret)); + +#ifdef TARGET_S390X + if (ret =3D=3D -EINVAL) { + error_printf("Host kernel setup problem detected." + " Please verify:\n"); + error_printf("- for kernels supporting the" + " switch_amode or user_mode parameters, whether"); + error_printf(" user space is running in primary address space\= n"); + error_printf("- for kernels supporting the vm.allocate_pgste" + " sysctl, whether it is enabled\n"); + } +#elif defined(TARGET_PPC) + if (ret =3D=3D -EINVAL) { + error_printf("PPC KVM module is not loaded. Try modprobe kvm_%= s.\n", + (type =3D=3D 2) ? "pr" : "hv"); + } +#endif + } + + return ret; +} + +static int find_kvm_machine_type(MachineState *ms) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + int type; + + if (object_property_find(OBJECT(current_machine), "kvm-type")) { + g_autofree char *kvm_type; + kvm_type =3D object_property_get_str(OBJECT(current_machine), + "kvm-type", + &error_abort); + type =3D mc->kvm_type(ms, kvm_type); + } else if (mc->kvm_type) { + type =3D mc->kvm_type(ms, NULL); + } else { + type =3D kvm_arch_get_default_type(ms); + } + return type; +} + static int kvm_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); @@ -2463,45 +2517,14 @@ static int kvm_init(MachineState *ms) } s->as =3D g_new0(struct KVMAs, s->nr_as); =20 - if (object_property_find(OBJECT(current_machine), "kvm-type")) { - g_autofree char *kvm_type =3D object_property_get_str(OBJECT(curre= nt_machine), - "kvm-type", - &error_abort); - type =3D mc->kvm_type(ms, kvm_type); - } else if (mc->kvm_type) { - type =3D mc->kvm_type(ms, NULL); - } else { - type =3D kvm_arch_get_default_type(ms); - } - + type =3D find_kvm_machine_type(ms); if (type < 0) { ret =3D -EINVAL; goto err; } =20 - do { - ret =3D kvm_ioctl(s, KVM_CREATE_VM, type); - } while (ret =3D=3D -EINTR); - + ret =3D do_kvm_create_vm(ms, type); if (ret < 0) { - error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret)); - -#ifdef TARGET_S390X - if (ret =3D=3D -EINVAL) { - error_printf("Host kernel setup problem detected." - " Please verify:\n"); - error_printf("- for kernels supporting the" - " switch_amode or user_mode parameters, whether"); - error_printf(" user space is running in primary address space\= n"); - error_printf("- for kernels supporting the vm.allocate_pgste" - " sysctl, whether it is enabled\n"); - } -#elif defined(TARGET_PPC) - if (ret =3D=3D -EINVAL) { - error_printf("PPC KVM module is not loaded. Try modprobe kvm_%= s.\n", - (type =3D=3D 2) ? "pr" : "hv"); - } -#endif goto err; } =20 --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059942; cv=none; d=zohomail.com; s=zohoarc; b=PGi2CJ7KnI0Fx/Ig5mSmNeOQXTJZH58JK+0GYWmo6lLupgEN2KOzMKTptGVRv9ZdgRz8oENLZRXZXEUhI+o/zK5UzfIVhEAM0YjqIw3FfyNUyShZqwqIaMzA74p4tDGuJ8b+B9IipA/VDQS9Lllr7YuHOk9FMUp9/RSArzusR9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059942; 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=g34hFuq4ii2wuTNDn7bYc7U1NVX9JTZP9beViRxwess=; b=mi9UzhzZ1toH/JXLHkMw43Fh/XwlwBpNjtLS8JKEW/W/s87GKnhQQdgEJPmYbf7pDRv8mO+APTqBlEhFS1JPMwltvNrAEttLoiNuJWiDWyC41ajSNSsaCHNFWGMf/s5fd6PYsWn9qx2rfwpnWx0uhgacjFXwZVPSJCVcgSAVpbM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059942662545.7355944218865; Fri, 4 Oct 2024 09:39:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlIU-000282-NV; Fri, 04 Oct 2024 12:36: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 1swlGf-0006xR-VP for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:02 -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 1swlGe-0006Ch-4G for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:01 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-bemiRuiLPUa15LKc8J-uZA-1; Fri, 04 Oct 2024 12:34:58 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb479fab2so15011555e9.1 for ; Fri, 04 Oct 2024 09:34:57 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1695e36dsm25679f8f.85.2024.10.04.09.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059699; 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=g34hFuq4ii2wuTNDn7bYc7U1NVX9JTZP9beViRxwess=; b=JnJ0SjRXMq157Vx68FfMOhCyxAea9zywyYsPBXpDcCpPtTA7uioolBk4Werj/SBYCBbQz8 L5Ua5NFyGUe5uSxqreJMkE5uixRUhXxwH5Xy8mL3k08AiEeVqCrn1YBGkdTPIHTCzm1+t2 eWfr/81bjEjS0qX7cyzgrkjW7Lh88/Q= X-MC-Unique: bemiRuiLPUa15LKc8J-uZA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059695; x=1728664495; 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=g34hFuq4ii2wuTNDn7bYc7U1NVX9JTZP9beViRxwess=; b=Xm7ckab0RndPkdNdQsTAmUPO0dc5r4xwhrmN6vToaxkr82+gKtUJRZ6D4HHuhAB7+f ux0T5DPpCIT0I3Njvms3OIgzh9gzoaFtn+2MMgckhpAE3IIja0oHEAM6o+YeB1W9T6/L 4XFMiHDuXq+dsPuJg4vgyPjDIbobddSxBgeOk2YqBLwaZZbYPv4nO4G34y/8vzBuQOgh hRi/PSBMgXLQwickziYR5RRRdnQQnfsxREiV7fqueF5ZOxUcliEOB9yZ4HV+H4PQDsZn Qpp2UKXqbYZoGzSe+B/QVN8nYREJEwrSbLecrbDUuV5NgBIC38t2I/wqtL1ZA9gUfSsS rZZg== X-Gm-Message-State: AOJu0Yz7Vll9PUzxsyJ0tYZrsK+cVqvF4G0h3EM+8z52h0PVGBUIr2n+ WMAFEl147KATjpQNvnU3/dD1sApluQblry4iGl/O2O/kHBzKGl6qrjqHfj0gl6FlTBisqqlcwRi R8e4hiP9b7DH/lXxSzZc/P+BJS9R+mlvpW+6ZJzv16qb3JR4KCDRQP6d6G7kJRpyk+/IdgMI4Zh UCN9hmJsCNowg+A602hf03/VP2afE+R8i9UqRUTXo= X-Received: by 2002:adf:fd45:0:b0:37c:ccdf:b69b with SMTP id ffacd0b85a97d-37d0f720763mr2077785f8f.32.1728059695281; Fri, 04 Oct 2024 09:34:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELdKljmSPFfr1nvOsl099TKUeQUAnfaZ19buy+s06EKRbkpCvAbcaeiWQ3QXZje9Pf/0FwUQ== X-Received: by 2002:adf:fd45:0:b0:37c:ccdf:b69b with SMTP id ffacd0b85a97d-37d0f720763mr2077763f8f.32.1728059694780; Fri, 04 Oct 2024 09:34:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Fabian Vogt Subject: [PULL 12/23] target/i386: Expose IBPB-BRTYPE and SBPB CPUID bits to the guest Date: Fri, 4 Oct 2024 18:34:04 +0200 Message-ID: <20241004163415.951106-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059944653116600 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas According to AMD's Speculative Return Stack Overflow whitepaper (link below), the hypervisor should synthesize the value of IBPB_BRTYPE and SBPB CPUID bits to the guest. Support for this is already present in the kernel with commit e47d86083c66 ("KVM: x86: Add SBPB support") and commit 6f0f23ef76be ("KVM: x86: Add IBPB_BRTYPE support"). Add support in QEMU to expose the bits to the guest OS. host: # cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow Mitigation: Safe RET before (guest): $ cpuid -l 0x80000021 -1 -r 0x80000021 0x00: eax=3D0x00000045 ebx=3D0x00000000 ecx=3D0x00000000 edx= =3D0x00000000 ^ $ cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow Vulnerable: Safe RET, no microcode after (guest): $ cpuid -l 0x80000021 -1 -r 0x80000021 0x00: eax=3D0x18000045 ebx=3D0x00000000 ecx=3D0x00000000 edx= =3D0x00000000 ^ $ cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow Mitigation: Safe RET Reported-by: Fabian Vogt Link: https://www.amd.com/content/dam/amd/en/documents/corporate/cr/specula= tive-return-stack-overflow-whitepaper.pdf Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240805202041.5936-1-farosas@suse.de Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 31f287cae05..ff227a8c5c8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1221,8 +1221,8 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, "sbpb", + "ibpb-brtype", NULL, NULL, NULL, }, .cpuid =3D { .eax =3D 0x80000021, .reg =3D R_EAX, }, .tcg_features =3D 0, --=20 2.46.1 From nobody Sat Nov 23 23:54:03 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060127; cv=none; d=zohomail.com; s=zohoarc; b=AhJ1mgRxi9JESTxB9KRdcQPmcz4yPQyf9vFd8+bZgdMD86QIxK7QE65sx7fRHtd2Z/c6d+1Zxt17Ps2f1Ai/dWF0Qk6l8OMULTkVz9hcKVOiuQlm3g4AO3Hacxk4zlrsmg2AcKmV4GdU0CKj0M9xxN0yhTqgOXD9aB3+fvgC6z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060127; 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=8nN9lqEG6YcOFZmpCVL2tbq4RA/rBtzOxA2lN9ZBgAA=; b=bFd5MFVdDjNC86z6TMCE5mKB7Xoi0HXMoXPhyx2IdFG0UNpq2YBoRbBc1rFQKPiJRwcNQPpI/6hSyVb7J1EEPR51nykCp41U3isEU+ANGWvztjCuhZXqUEoMmf2/5pUBrlJYH9yV+eYsEzNQbfKKZ274/cKYgvDDQ3/p9xfFa/s= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060127536129.33643331414612; Fri, 4 Oct 2024 09:42:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlIn-0002ip-DH; Fri, 04 Oct 2024 12:37: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 1swlGi-0006ze-Ct for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:06 -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 1swlGg-0006DP-SP for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:04 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-zRvP1hRaNtWldhw5gQdhfg-1; Fri, 04 Oct 2024 12:35:00 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42e611963c2so17702995e9.1 for ; Fri, 04 Oct 2024 09:35:00 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89e85778sm1629705e9.2.2024.10.04.09.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059702; 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=8nN9lqEG6YcOFZmpCVL2tbq4RA/rBtzOxA2lN9ZBgAA=; b=e3Y7bqFbJ/CK5PEyjsFNhZQaLouif1UKPvzneqf6rLF+6F9X/MpArNYS9eFXLeTbieUMXY JyUdQtEzxt18cY1c6jElMfzBok8J/Et4j6jarvlmnrdYQ/mIHUVs/56XPxJyoZuSvT6uJ6 8AQBmpR/PgyQBDpm4pnw1oKMeGUdFMI= X-MC-Unique: zRvP1hRaNtWldhw5gQdhfg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059699; x=1728664499; 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=8nN9lqEG6YcOFZmpCVL2tbq4RA/rBtzOxA2lN9ZBgAA=; b=KKH1zxMKneIUXIaV5wgAnD2RnEVT3zUXXV5RZ4ZaXDB1hwiK5T4TJSkNinxtGOXu8m iptfedhpy0+ewKcDOofS3ly39VFOAzW6iynipklGYRxlVlKUhDgfD0TX5eoNKW0Ih2dS P+Xtqlfbm2tef070Bg7dIgiYh7hdhKYJ8+Ld9U/+bvr76gIhfgvEj/x0rdgk7q3X3OFA x3FInH/OaedIh7i78A+tIL3SfD8VPEoOB8SVQP64qjix6kAI/GrqEIMivyuAUXzi/lZe 42OzKK/sVzgHNeYYvbebKaERkaUa2yx97hOVernLaAUUrerbLfSCx7cVX9sgV1fhXuaf yJaA== X-Gm-Message-State: AOJu0YxJqOKtxT+LAS8FoJHuWTVV4k061F3zz7cl7+DOMVMrbu/RxvaK zm7XTwiHZhdWCnA7/PXxxeSt/QFoEXF31Nz0yfO+jia7Ub+QV0R+jij4dqdh5KGp/pSU6OC/un+ VFU+Gl6pxD7K+XiA64yoGmbVeupT1sxVQkLBeHtEdRWYPZBlcrZMtCvpcrNUR8hiHNSbsLFfiZC bd97I0e1i268qkp1D1T7dfnwMb1GOO4T+Rt8cXwYU= X-Received: by 2002:a05:600c:1d17:b0:42c:a574:636b with SMTP id 5b1f17b1804b1-42f85af1018mr22036755e9.35.1728059698864; Fri, 04 Oct 2024 09:34:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv5572tI7UODNf578Zd2izTMW7BWrig8ntuTEUDPvciPEPAX9wXCi5kNKF2Ev1IlN7vH1u6g== X-Received: by 2002:a05:600c:1d17:b0:42c:a574:636b with SMTP id 5b1f17b1804b1-42f85af1018mr22036595e9.35.1728059698413; Fri, 04 Oct 2024 09:34:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow , Mark Cave-Ayland Subject: [PULL 13/23] hw: Remove unused inclusion of hw/char/serial.h Date: Fri, 4 Oct 2024 18:34:05 +0200 Message-ID: <20241004163415.951106-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060129620116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Reviewed-by: Mark Cave-Ayland Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20240905073832.16222-2-shentey@gmail.com Signed-off-by: Paolo Bonzini --- hw/char/riscv_htif.c | 1 - hw/ppc/prep.c | 1 - hw/riscv/sifive_e.c | 1 - hw/riscv/sifive_u.c | 1 - 4 files changed, 4 deletions(-) diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c index 9bef60def1b..54fd55c3e6f 100644 --- a/hw/char/riscv_htif.c +++ b/hw/char/riscv_htif.c @@ -24,7 +24,6 @@ #include "qapi/error.h" #include "qemu/log.h" #include "hw/char/riscv_htif.h" -#include "hw/char/serial.h" #include "chardev/char.h" #include "chardev/char-fe.h" #include "qemu/timer.h" diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 4eb54770690..fb58c312acc 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -25,7 +25,6 @@ =20 #include "qemu/osdep.h" #include "hw/rtc/m48t59.h" -#include "hw/char/serial.h" #include "hw/block/fdc.h" #include "net/net.h" #include "hw/isa/isa.h" diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 87d9602383a..5a1959f2a9e 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -35,7 +35,6 @@ #include "hw/boards.h" #include "hw/loader.h" #include "hw/sysbus.h" -#include "hw/char/serial.h" #include "hw/misc/unimp.h" #include "target/riscv/cpu.h" #include "hw/riscv/riscv_hart.h" diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index af5f923f541..efc8443c844 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -43,7 +43,6 @@ #include "hw/irq.h" #include "hw/loader.h" #include "hw/sysbus.h" -#include "hw/char/serial.h" #include "hw/cpu/cluster.h" #include "hw/misc/unimp.h" #include "hw/sd/sd.h" --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059858; cv=none; d=zohomail.com; s=zohoarc; b=lSw7gnCS13bCQ97VAEAdvaHc7ZkmPG4Ky3RTRZUvPFjNnUxNb9O2ZXRwzRs8D9U9AEa38rObpeuA1SrvVBZKzZasbU6yn5Sti6f3Qvq1wKnHKj6NBoFkfScfvQYOHuO5G8bY/kkGmz1SC733LuqtduqD53H+5IXee3+sQIKVehc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059858; 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=jdVFzb9L18j2pnmUeuxlHxonmR/Z1HZ0HNAjMMPuaSg=; b=Qf/EF/nwgj4+ks51aTxIkspQoz/aLseku/eI/UcKC2k5wLuqivEOQdClVxQTT6sLi29F98L3IH8eTuM2f0gUNHJ7j6luGobEZhmN0EDUL1yEaUGQITR0v+4k5LEUJAKgctzUBagHgey9aqQlRmi6/Qc1LN1+MnMV2kc47meJ/HQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059858561156.75835038520302; Fri, 4 Oct 2024 09:37:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlIt-00030C-A8; Fri, 04 Oct 2024 12:37:19 -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 1swlGm-0007DX-WA for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:11 -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 1swlGk-0006Oc-Rm for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:08 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-Nw1ZTLxCPqyZjQtG51mlhQ-1; Fri, 04 Oct 2024 12:35:04 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb940cd67so22349215e9.0 for ; Fri, 04 Oct 2024 09:35:04 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d16972b2esm23580f8f.105.2024.10.04.09.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059705; 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=jdVFzb9L18j2pnmUeuxlHxonmR/Z1HZ0HNAjMMPuaSg=; b=Ac6Qso1D5b/kVjhj5VIPbbat1Ntx/JO+ylu6NK9J1qD8r5bUZXg2sqTe204wTMvUgr5YWZ xe0ayuPdLfOMkZkRf9FKa50rfI0k6ZL9tBswvGeIqVt2ZYHpdjBZCs5AXTE+lUWuDnVEvM CuLr6PRrBBuzrRwepfghQOls4GNz/YY= X-MC-Unique: Nw1ZTLxCPqyZjQtG51mlhQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059702; x=1728664502; 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=jdVFzb9L18j2pnmUeuxlHxonmR/Z1HZ0HNAjMMPuaSg=; b=KNykf51Dqk9v3UFSzQK0XK+TftS3RTqN7nMz3RpguhG/PtjP8a8CEhBADFE8D2tBc0 ZGhIqV3wwv9Z5LFBmBC7rf9i7fxRog6os3CslTJP3H9mug9NJmoK9cAb4ReXpdxd7StX ZwQQCMJAywBTUGCntlqzHfnL6AJHXtpfA0CqyrxI2LBqNsoIOVcqVNDwQKhjqR2a1fdj Kc3bqrx/gwrtT+Y5Yg3axfE8eIeXUV47aevS3Nv4diSmlLucxSuCg9RfVYjl6oiTG29e 4N+oRhCB2m5UVQk1aeh6wBtMgCwi14VBCTyPlEX03fbbMG+s3FzUtHofhJiopeFDMZHW Z4Iw== X-Gm-Message-State: AOJu0YwWlTRdkDgLtHWPSPkiyvOVOf8eYwrjwrEiQgLq2FQJrd2FbdCT XGSf/4ai6fiAwreQwGp4hHgFQ9C6PisTgIl5mGc2Pk3HqvzRU6WrEI2dmeY4IPBsm0HggzIdoR5 /XUVvryn1GZ5UcaDUpCS+lgheXBvhSSgSahimNul3DH2cSjyauiDPKJ8aPZ0ddD+PbfzqcGwmjT s13aqtB1GDHEQlcu5cN+987PIInRJZH21FoqyhYTY= X-Received: by 2002:a05:600c:3c9c:b0:42c:bae0:f05f with SMTP id 5b1f17b1804b1-42f85aa98ddmr31420915e9.13.1728059701999; Fri, 04 Oct 2024 09:35:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZZa22lqBVXcpeHJXVydGQTXKXOsXPzc7gIIiU1Aof+3bfmxWpQ+l8bBH+QH7fRuZwwpA6tQ== X-Received: by 2002:a05:600c:3c9c:b0:42c:bae0:f05f with SMTP id 5b1f17b1804b1-42f85aa98ddmr31420615e9.13.1728059701389; Fri, 04 Oct 2024 09:35:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow , Mark Cave-Ayland Subject: [PULL 14/23] hw/char/serial.h: Extract serial-isa.h Date: Fri, 4 Oct 2024 18:34:06 +0200 Message-ID: <20241004163415.951106-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059860174116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow The includes where updated based on compile errors. Now, the inclusion of t= he header roughly matches Kconfig dependencies: # grep -r -e "select SERIAL_ISA" hw/ppc/Kconfig: select SERIAL_ISA hw/isa/Kconfig: select SERIAL_ISA hw/sparc64/Kconfig: select SERIAL_ISA hw/i386/Kconfig: select SERIAL_ISA hw/i386/Kconfig: select SERIAL_ISA # for serial_hds_isa_init() Reviewed-by: Mark Cave-Ayland Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20240905073832.16222-3-shentey@gmail.com Signed-off-by: Paolo Bonzini --- include/hw/char/serial-isa.h | 38 ++++++++++++++++++++++++++++++++++++ include/hw/char/serial.h | 9 --------- hw/char/serial-isa.c | 1 + hw/i386/microvm-dt.c | 2 +- hw/i386/microvm.c | 2 +- hw/i386/pc.c | 2 +- hw/isa/isa-superio.c | 2 +- hw/isa/vt82c686.c | 2 +- hw/ppc/pnv.c | 2 +- hw/sparc64/sun4u.c | 1 + 10 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 include/hw/char/serial-isa.h diff --git a/include/hw/char/serial-isa.h b/include/hw/char/serial-isa.h new file mode 100644 index 00000000000..8517afa128a --- /dev/null +++ b/include/hw/char/serial-isa.h @@ -0,0 +1,38 @@ +/* + * QEMU ISA 16550A UART emulation + * + * Copyright (c) 2003-2004 Fabrice Bellard + * Copyright (c) 2008 Citrix Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef HW_SERIAL_ISA_H +#define HW_SERIAL_ISA_H + +#include "hw/isa/isa.h" + +#define MAX_ISA_SERIAL_PORTS 4 + +#define TYPE_ISA_SERIAL "isa-serial" +void serial_hds_isa_init(ISABus *bus, int from, int to); +void isa_serial_set_iobase(ISADevice *serial, hwaddr iobase); +void isa_serial_set_enabled(ISADevice *serial, bool enabled); + +#endif diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index 6e14099ee7f..fca32a532b9 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -106,13 +106,4 @@ SerialMM *serial_mm_init(MemoryRegion *address_space, qemu_irq irq, int baudbase, Chardev *chr, enum device_endian end); =20 -/* serial-isa.c */ - -#define MAX_ISA_SERIAL_PORTS 4 - -#define TYPE_ISA_SERIAL "isa-serial" -void serial_hds_isa_init(ISABus *bus, int from, int to); -void isa_serial_set_iobase(ISADevice *serial, hwaddr iobase); -void isa_serial_set_enabled(ISADevice *serial, bool enabled); - #endif diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index 329b352b9a8..b562ec9d37c 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -29,6 +29,7 @@ #include "sysemu/sysemu.h" #include "hw/acpi/acpi_aml_interface.h" #include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c index b3049e4f9f2..fc5db6ed7ff 100644 --- a/hw/i386/microvm-dt.c +++ b/hw/i386/microvm-dt.c @@ -34,7 +34,7 @@ #include "qemu/cutils.h" #include "qapi/error.h" #include "sysemu/device_tree.h" -#include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/i386/fw_cfg.h" #include "hw/rtc/mc146818rtc.h" #include "hw/sysbus.h" diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 8ae4dff7f2e..693099f2256 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -39,7 +39,7 @@ #include "hw/intc/i8259.h" #include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h" -#include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/display/ramfb.h" #include "hw/i386/topology.h" #include "hw/i386/e820_memory_layout.h" diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 67a921779ca..2047633e4cf 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "hw/i386/pc.h" -#include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/char/parallel.h" #include "hw/hyperv/hv-balloon.h" #include "hw/i386/fw_cfg.h" diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index a8c8c58ef7f..cff756e791b 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -22,7 +22,7 @@ #include "hw/qdev-properties.h" #include "hw/input/i8042.h" #include "hw/char/parallel-isa.h" -#include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "trace.h" =20 static void isa_superio_realize(DeviceState *dev, Error **errp) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 4ad8e1293cf..6f44b381a5f 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -17,7 +17,7 @@ #include "hw/isa/vt82c686.h" #include "hw/block/fdc.h" #include "hw/char/parallel-isa.h" -#include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" #include "hw/ide/pci.h" diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 988fd55d880..795acc289fa 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -53,7 +53,7 @@ #include "hw/ppc/pnv_pnor.h" =20 #include "hw/isa/isa.h" -#include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/rtc/mc146818rtc.h" =20 #include diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 4ece1ac1ffc..a839abbf5d0 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -35,6 +35,7 @@ #include "hw/qdev-properties.h" #include "hw/pci-host/sabre.h" #include "hw/char/serial.h" +#include "hw/char/serial-isa.h" #include "hw/char/parallel-isa.h" #include "hw/rtc/m48t59.h" #include "migration/vmstate.h" --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059848; cv=none; d=zohomail.com; s=zohoarc; b=dlWVW8zbs9lbRsUpT75/kclbZL3VE8z58tKCYFgB0I8YT74LZHlXgatMmDjmjATbJyAKERaJF06YWSQOK7m1UePpTtA7iZbPq9mfmdGIncuKXH4us4KXEGiPtF1FFHUfVbXbF7Hh/lw1cf8YDzfH+ydGfACl2AyIlL1OWDJU2NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059848; 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=bGdYm7I2qI5DeApKFtTybWUF55z//A6DNOdCUXcsPho=; b=I3KDCGY1ZXUEjI6FyH3Xztmu4nXwrjx3+ZHCKTwMTzYdPB41bY/cRIlyk9AgYrQdTP2YM2beT9l207o7XUaagPVgb3oMOSPy22FS/Yi+BwwgzzD6KG1Zl05WrbS5fHsLUMwSm++c+ISAXGGCJL4zU4NWo1BzrHhsjoH8vXY3dp4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172805984891141.66490235174399; Fri, 4 Oct 2024 09:37:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlH6-00006J-Kn; Fri, 04 Oct 2024 12:35: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 1swlGu-0007eb-5c for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:16 -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 1swlGo-0006PP-LH for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:15 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-0cmOHY5hP_yCWH_xNMCXog-1; Fri, 04 Oct 2024 12:35:07 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37cd6655ef0so1096282f8f.3 for ; Fri, 04 Oct 2024 09:35:07 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89ec644dsm1498375e9.37.2024.10.04.09.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059709; 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=bGdYm7I2qI5DeApKFtTybWUF55z//A6DNOdCUXcsPho=; b=HE/74BR2X7v7AB7vjbdLOAxur8252EFiEBx06F3F8q/uJnP0ecFhPqOiUHOcMC22Wz9164 s7+CgCjJNs2UnKFVaqbTLFlyLXhYYo9uB88bli2jXievwExPnQEqtWBor9Of5vOIW8BtnE 1jJ7jcs2givBN0Qlh/HiSE5qYl/9c4k= X-MC-Unique: 0cmOHY5hP_yCWH_xNMCXog-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059706; x=1728664506; 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=bGdYm7I2qI5DeApKFtTybWUF55z//A6DNOdCUXcsPho=; b=uoTAa5ryCWK8EUjH9aaBVfMnPiMCjKHMWSphLV2yR5mf5zoRmHkWIe723+jFWBY7IR KYhAlEJnfUCKPZFfXSt8/YFX4xLsVUULU2dw09iqjBa25ii+ZD6+dv+HVhsN34SscNTl h9lXBgW2MffHVcLHSJN0w54izKGtLw64+d5sBQ+z+QZfvcIM7xyqekewO5gbyg8nA/TI HZB+7vo1ZPtEi+nH1oHI2Ki8eUDLV67O/Ymdv3Iqt+90DsYN2tfvnEIsGh5GsUFR91N/ RI+kLBrt4B7+QDJl2MFPujVkEEotorBywlfdfSQINJBUA2f37h098/oqLFKIXQ1R7Nba VJFA== X-Gm-Message-State: AOJu0YzGLo3Ikw0QlOzZtySRydK6sGebrjIojvPcJpr1US76s6unEZQ5 L3sV9SUhhUZK7hVO0b7H1MPJP+0Zl85rEa+d0clRWXKkzmt9LVR2Yxgfje4eDjdtAFZrSZybzrW 3wPtu7ApszT7SLxPO8+NiboCdPtQnzoDH4baNOu2bN1nZKYbFZlGjz/Bob79HzMCMVgXzrppcYU pY+5hj0T5YOhIPYpPrKaE5+Ql9hvhvDpy9K2jePKM= X-Received: by 2002:a05:6000:1370:b0:37c:d248:80ff with SMTP id ffacd0b85a97d-37d0e734428mr2398834f8f.24.1728059705559; Fri, 04 Oct 2024 09:35:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDC8tjQ8jG0MNvV9wDyMZdat7Qphs35dBGKP8WsoRFT8Xz+OiEsc7TPlt1hRfxPEC5BERXvA== X-Received: by 2002:a05:6000:1370:b0:37c:d248:80ff with SMTP id ffacd0b85a97d-37d0e734428mr2398798f8f.24.1728059704684; Fri, 04 Oct 2024 09:35:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow , Andrew Jeffery , Mark Cave-Ayland Subject: [PULL 15/23] hw/char: Extract serial-mm Date: Fri, 4 Oct 2024 18:34:07 +0200 Message-ID: <20241004163415.951106-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059850301116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow hw/char/serial currently contains the implementation of both TYPE_SERIAL and TYPE_SERIAL_MM. According to serial_class_init(), TYPE_SERIAL is an internal class while TYPE_SERIAL_MM is used by numerous machine types directly. Let's move the latter into its own module which makes the dependencies more obvio= us and the code more tidy. The includes and the dependencies have been converted mechanically except i= n the hw/char directories which were updated manually. The result was compile-tes= ted. Now, only hw/char makes direct use of TYPE_SERIAL: # grep -r -e "select SERIAL" | grep -v SERIAL_ hw/char/Kconfig: select SERIAL hw/char/Kconfig: select SERIAL hw/char/Kconfig: select SERIAL hw/char/Kconfig: select SERIAL hw/char/Kconfig: select SERIAL # grep -r -e "/serial\\.h" include/hw/char/serial-mm.h:#include "hw/char/serial.h" hw/char/serial-pci-multi.c:#include "hw/char/serial.h" hw/char/serial.c:#include "hw/char/serial.h" hw/char/serial-isa.c:#include "hw/char/serial.h" hw/char/serial-pci.c:#include "hw/char/serial.h" Tested-by: Andrew Jeffery Reviewed-by: Mark Cave-Ayland Signed-off-by: Bernhard Beschow Link: https://lore.kernel.org/r/20240905073832.16222-4-shentey@gmail.com Signed-off-by: Paolo Bonzini --- include/hw/arm/aspeed_soc.h | 2 +- include/hw/char/mchp_pfsoc_mmuart.h | 2 +- include/hw/char/serial-mm.h | 52 +++++++++ include/hw/char/serial.h | 19 ---- hw/arm/allwinner-a10.c | 2 +- hw/arm/allwinner-h3.c | 2 +- hw/arm/allwinner-r40.c | 2 +- hw/arm/aspeed_ast2400.c | 2 +- hw/arm/aspeed_soc_common.c | 2 +- hw/arm/kzm.c | 2 +- hw/arm/msf2-soc.c | 2 +- hw/arm/musicpal.c | 2 +- hw/arm/npcm7xx.c | 2 +- hw/arm/pxa2xx.c | 2 +- hw/char/omap_uart.c | 2 +- hw/char/serial-mm.c | 157 ++++++++++++++++++++++++++++ hw/char/serial.c | 126 ---------------------- hw/display/sm501.c | 2 +- hw/hppa/machine.c | 2 +- hw/loongarch/virt.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 2 +- hw/mips/boston.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 2 +- hw/mips/mipssim.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- hw/openrisc/virt.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/ppc405_uc.c | 2 +- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/sam460ex.c | 2 +- hw/ppc/virtex_ml507.c | 2 +- hw/riscv/virt.c | 2 +- hw/sparc64/niagara.c | 2 +- hw/sparc64/sun4u.c | 2 +- hw/xtensa/xtfpga.c | 2 +- hw/arm/Kconfig | 20 ++-- hw/char/Kconfig | 4 + hw/char/meson.build | 1 + hw/display/Kconfig | 2 +- hw/hppa/Kconfig | 2 +- hw/loongarch/Kconfig | 2 +- hw/microblaze/Kconfig | 2 +- hw/mips/Kconfig | 10 +- hw/openrisc/Kconfig | 4 +- hw/ppc/Kconfig | 10 +- hw/riscv/Kconfig | 2 +- hw/sparc64/Kconfig | 1 + hw/xtensa/Kconfig | 2 +- 50 files changed, 276 insertions(+), 206 deletions(-) create mode 100644 include/hw/char/serial-mm.h create mode 100644 hw/char/serial-mm.c diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 624d489e0d6..689f52dae8f 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -39,7 +39,7 @@ #include "hw/misc/unimp.h" #include "hw/misc/aspeed_peci.h" #include "hw/fsi/aspeed_apb2opb.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/intc/arm_gicv3.h" =20 #define ASPEED_SPIS_NUM 2 diff --git a/include/hw/char/mchp_pfsoc_mmuart.h b/include/hw/char/mchp_pfs= oc_mmuart.h index b0e14ca3554..a7b8b1b08b3 100644 --- a/include/hw/char/mchp_pfsoc_mmuart.h +++ b/include/hw/char/mchp_pfsoc_mmuart.h @@ -29,7 +29,7 @@ #define HW_MCHP_PFSOC_MMUART_H =20 #include "hw/sysbus.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" =20 #define MCHP_PFSOC_MMUART_REG_COUNT 13 =20 diff --git a/include/hw/char/serial-mm.h b/include/hw/char/serial-mm.h new file mode 100644 index 00000000000..62a8489d694 --- /dev/null +++ b/include/hw/char/serial-mm.h @@ -0,0 +1,52 @@ +/* + * QEMU 16550A UART emulation + * + * Copyright (c) 2003-2004 Fabrice Bellard + * Copyright (c) 2008 Citrix Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef HW_SERIAL_MM_H +#define HW_SERIAL_MM_H + +#include "hw/char/serial.h" +#include "exec/memory.h" +#include "chardev/char.h" +#include "hw/sysbus.h" +#include "qom/object.h" + +#define TYPE_SERIAL_MM "serial-mm" +OBJECT_DECLARE_SIMPLE_TYPE(SerialMM, SERIAL_MM) + +struct SerialMM { + SysBusDevice parent; + + SerialState serial; + + uint8_t regshift; + uint8_t endianness; +}; + +SerialMM *serial_mm_init(MemoryRegion *address_space, + hwaddr base, int regshift, + qemu_irq irq, int baudbase, + Chardev *chr, enum device_endian end); + +#endif diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index fca32a532b9..18952e2942b 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -29,8 +29,6 @@ #include "chardev/char-fe.h" #include "exec/memory.h" #include "qemu/fifo8.h" -#include "chardev/char.h" -#include "hw/sysbus.h" #include "qom/object.h" =20 #define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */ @@ -81,15 +79,6 @@ struct SerialState { }; typedef struct SerialState SerialState; =20 -struct SerialMM { - SysBusDevice parent; - - SerialState serial; - - uint8_t regshift; - uint8_t endianness; -}; - extern const VMStateDescription vmstate_serial; extern const MemoryRegionOps serial_io_ops; =20 @@ -98,12 +87,4 @@ void serial_set_frequency(SerialState *s, uint32_t frequ= ency); #define TYPE_SERIAL "serial" OBJECT_DECLARE_SIMPLE_TYPE(SerialState, SERIAL) =20 -#define TYPE_SERIAL_MM "serial-mm" -OBJECT_DECLARE_SIMPLE_TYPE(SerialMM, SERIAL_MM) - -SerialMM *serial_mm_init(MemoryRegion *address_space, - hwaddr base, int regshift, - qemu_irq irq, int baudbase, - Chardev *chr, enum device_endian end); - #endif diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 57d5d80159c..08cdff61e46 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -18,7 +18,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/sysbus.h" #include "hw/arm/allwinner-a10.h" #include "hw/misc/unimp.h" diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c index 6870c3fe963..9bc57cd2666 100644 --- a/hw/arm/allwinner-h3.c +++ b/hw/arm/allwinner-h3.c @@ -24,7 +24,7 @@ #include "qemu/units.h" #include "hw/qdev-core.h" #include "hw/sysbus.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/misc/unimp.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c index b8c72021334..ced73009d63 100644 --- a/hw/arm/allwinner-r40.c +++ b/hw/arm/allwinner-r40.c @@ -26,7 +26,7 @@ #include "hw/boards.h" #include "hw/qdev-core.h" #include "hw/sysbus.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/misc/unimp.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" diff --git a/hw/arm/aspeed_ast2400.c b/hw/arm/aspeed_ast2400.c index d1258862075..ecc81ecc79c 100644 --- a/hw/arm/aspeed_ast2400.c +++ b/hw/arm/aspeed_ast2400.c @@ -15,7 +15,7 @@ #include "qapi/error.h" #include "hw/misc/unimp.h" #include "hw/arm/aspeed_soc.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "qemu/module.h" #include "qemu/error-report.h" #include "hw/i2c/aspeed_i2c.h" diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c index 05551461aea..a5ff33c46d7 100644 --- a/hw/arm/aspeed_soc_common.c +++ b/hw/arm/aspeed_soc_common.c @@ -15,7 +15,7 @@ #include "hw/qdev-properties.h" #include "hw/misc/unimp.h" #include "hw/arm/aspeed_soc.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" =20 =20 const char *aspeed_soc_cpu_type(AspeedSoCClass *sc) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index 2ccd6f8a768..fbd140e3833 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -22,7 +22,7 @@ #include "exec/address-spaces.h" #include "net/net.h" #include "hw/net/lan9118.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "sysemu/qtest.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c index a94a10adcca..c4999ebce38 100644 --- a/hw/arm/msf2-soc.c +++ b/hw/arm/msf2-soc.c @@ -26,7 +26,7 @@ #include "qemu/units.h" #include "qapi/error.h" #include "exec/address-spaces.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/arm/msf2-soc.h" #include "hw/misc/unimp.h" #include "hw/qdev-clock.h" diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index 3293f04d221..33ece06bbd6 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -18,7 +18,7 @@ #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "qemu/timer.h" #include "hw/ptimer.h" #include "hw/qdev-properties.h" diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index cb7791301b4..af04c4b7ec4 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -18,7 +18,7 @@ =20 #include "hw/arm/boot.h" #include "hw/arm/npcm7xx.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/loader.h" #include "hw/misc/unimp.h" #include "hw/qdev-clock.h" diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c index 23e1aecc942..7ce67b9af76 100644 --- a/hw/arm/pxa2xx.c +++ b/hw/arm/pxa2xx.c @@ -17,7 +17,7 @@ #include "migration/vmstate.h" #include "hw/arm/pxa.h" #include "sysemu/sysemu.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c index c2ef4c137e1..6ec04299960 100644 --- a/hw/char/omap_uart.c +++ b/hw/char/omap_uart.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "chardev/char.h" #include "hw/arm/omap.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "exec/address-spaces.h" =20 /* UARTs */ diff --git a/hw/char/serial-mm.c b/hw/char/serial-mm.c new file mode 100644 index 00000000000..2f67776b190 --- /dev/null +++ b/hw/char/serial-mm.c @@ -0,0 +1,157 @@ +/* + * QEMU 16550A UART emulation + * + * Copyright (c) 2003-2004 Fabrice Bellard + * Copyright (c) 2008 Citrix Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "hw/char/serial-mm.h" +#include "exec/cpu-common.h" +#include "migration/vmstate.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" + +static uint64_t serial_mm_read(void *opaque, hwaddr addr, unsigned size) +{ + SerialMM *s =3D SERIAL_MM(opaque); + return serial_io_ops.read(&s->serial, addr >> s->regshift, 1); +} + +static void serial_mm_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size) +{ + SerialMM *s =3D SERIAL_MM(opaque); + value &=3D 255; + serial_io_ops.write(&s->serial, addr >> s->regshift, value, 1); +} + +static const MemoryRegionOps serial_mm_ops[3] =3D { + [DEVICE_NATIVE_ENDIAN] =3D { + .read =3D serial_mm_read, + .write =3D serial_mm_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid.max_access_size =3D 8, + .impl.max_access_size =3D 8, + }, + [DEVICE_LITTLE_ENDIAN] =3D { + .read =3D serial_mm_read, + .write =3D serial_mm_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid.max_access_size =3D 8, + .impl.max_access_size =3D 8, + }, + [DEVICE_BIG_ENDIAN] =3D { + .read =3D serial_mm_read, + .write =3D serial_mm_write, + .endianness =3D DEVICE_BIG_ENDIAN, + .valid.max_access_size =3D 8, + .impl.max_access_size =3D 8, + }, +}; + +static void serial_mm_realize(DeviceState *dev, Error **errp) +{ + SerialMM *smm =3D SERIAL_MM(dev); + SerialState *s =3D &smm->serial; + + if (!qdev_realize(DEVICE(s), NULL, errp)) { + return; + } + + memory_region_init_io(&s->io, OBJECT(dev), + &serial_mm_ops[smm->endianness], smm, "serial", + 8 << smm->regshift); + sysbus_init_mmio(SYS_BUS_DEVICE(smm), &s->io); + sysbus_init_irq(SYS_BUS_DEVICE(smm), &smm->serial.irq); +} + +static const VMStateDescription vmstate_serial_mm =3D { + .name =3D "serial", + .version_id =3D 3, + .minimum_version_id =3D 2, + .fields =3D (const VMStateField[]) { + VMSTATE_STRUCT(serial, SerialMM, 0, vmstate_serial, SerialState), + VMSTATE_END_OF_LIST() + } +}; + +SerialMM *serial_mm_init(MemoryRegion *address_space, + hwaddr base, int regshift, + qemu_irq irq, int baudbase, + Chardev *chr, enum device_endian end) +{ + SerialMM *smm =3D SERIAL_MM(qdev_new(TYPE_SERIAL_MM)); + MemoryRegion *mr; + + qdev_prop_set_uint8(DEVICE(smm), "regshift", regshift); + qdev_prop_set_uint32(DEVICE(smm), "baudbase", baudbase); + qdev_prop_set_chr(DEVICE(smm), "chardev", chr); + qdev_set_legacy_instance_id(DEVICE(smm), base, 2); + qdev_prop_set_uint8(DEVICE(smm), "endianness", end); + sysbus_realize_and_unref(SYS_BUS_DEVICE(smm), &error_fatal); + + sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, irq); + mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(smm), 0); + memory_region_add_subregion(address_space, base, mr); + + return smm; +} + +static void serial_mm_instance_init(Object *o) +{ + SerialMM *smm =3D SERIAL_MM(o); + + object_initialize_child(o, "serial", &smm->serial, TYPE_SERIAL); + + qdev_alias_all_properties(DEVICE(&smm->serial), o); +} + +static Property serial_mm_properties[] =3D { + /* + * Set the spacing between adjacent memory-mapped UART registers. + * Each register will be at (1 << regshift) bytes after the previous o= ne. + */ + DEFINE_PROP_UINT8("regshift", SerialMM, regshift, 0), + DEFINE_PROP_UINT8("endianness", SerialMM, endianness, DEVICE_NATIVE_EN= DIAN), + DEFINE_PROP_END_OF_LIST(), +}; + +static void serial_mm_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + + device_class_set_props(dc, serial_mm_properties); + dc->realize =3D serial_mm_realize; + dc->vmsd =3D &vmstate_serial_mm; +} + +static const TypeInfo types[] =3D { + { + .name =3D TYPE_SERIAL_MM, + .parent =3D TYPE_SYS_BUS_DEVICE, + .class_init =3D serial_mm_class_init, + .instance_init =3D serial_mm_instance_init, + .instance_size =3D sizeof(SerialMM), + }, +}; + +DEFINE_TYPES(types) diff --git a/hw/char/serial.c b/hw/char/serial.c index d8b2db50829..1e972950e88 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -996,135 +996,9 @@ static const TypeInfo serial_info =3D { .class_init =3D serial_class_init, }; =20 -/* Memory mapped interface */ -static uint64_t serial_mm_read(void *opaque, hwaddr addr, - unsigned size) -{ - SerialMM *s =3D SERIAL_MM(opaque); - return serial_ioport_read(&s->serial, addr >> s->regshift, 1); -} - -static void serial_mm_write(void *opaque, hwaddr addr, - uint64_t value, unsigned size) -{ - SerialMM *s =3D SERIAL_MM(opaque); - value &=3D 255; - serial_ioport_write(&s->serial, addr >> s->regshift, value, 1); -} - -static const MemoryRegionOps serial_mm_ops[3] =3D { - [DEVICE_NATIVE_ENDIAN] =3D { - .read =3D serial_mm_read, - .write =3D serial_mm_write, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .valid.max_access_size =3D 8, - .impl.max_access_size =3D 8, - }, - [DEVICE_LITTLE_ENDIAN] =3D { - .read =3D serial_mm_read, - .write =3D serial_mm_write, - .endianness =3D DEVICE_LITTLE_ENDIAN, - .valid.max_access_size =3D 8, - .impl.max_access_size =3D 8, - }, - [DEVICE_BIG_ENDIAN] =3D { - .read =3D serial_mm_read, - .write =3D serial_mm_write, - .endianness =3D DEVICE_BIG_ENDIAN, - .valid.max_access_size =3D 8, - .impl.max_access_size =3D 8, - }, -}; - -static void serial_mm_realize(DeviceState *dev, Error **errp) -{ - SerialMM *smm =3D SERIAL_MM(dev); - SerialState *s =3D &smm->serial; - - if (!qdev_realize(DEVICE(s), NULL, errp)) { - return; - } - - memory_region_init_io(&s->io, OBJECT(dev), - &serial_mm_ops[smm->endianness], smm, "serial", - 8 << smm->regshift); - sysbus_init_mmio(SYS_BUS_DEVICE(smm), &s->io); - sysbus_init_irq(SYS_BUS_DEVICE(smm), &smm->serial.irq); -} - -static const VMStateDescription vmstate_serial_mm =3D { - .name =3D "serial", - .version_id =3D 3, - .minimum_version_id =3D 2, - .fields =3D (const VMStateField[]) { - VMSTATE_STRUCT(serial, SerialMM, 0, vmstate_serial, SerialState), - VMSTATE_END_OF_LIST() - } -}; - -SerialMM *serial_mm_init(MemoryRegion *address_space, - hwaddr base, int regshift, - qemu_irq irq, int baudbase, - Chardev *chr, enum device_endian end) -{ - SerialMM *smm =3D SERIAL_MM(qdev_new(TYPE_SERIAL_MM)); - MemoryRegion *mr; - - qdev_prop_set_uint8(DEVICE(smm), "regshift", regshift); - qdev_prop_set_uint32(DEVICE(smm), "baudbase", baudbase); - qdev_prop_set_chr(DEVICE(smm), "chardev", chr); - qdev_set_legacy_instance_id(DEVICE(smm), base, 2); - qdev_prop_set_uint8(DEVICE(smm), "endianness", end); - sysbus_realize_and_unref(SYS_BUS_DEVICE(smm), &error_fatal); - - sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, irq); - mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(smm), 0); - memory_region_add_subregion(address_space, base, mr); - - return smm; -} - -static void serial_mm_instance_init(Object *o) -{ - SerialMM *smm =3D SERIAL_MM(o); - - object_initialize_child(o, "serial", &smm->serial, TYPE_SERIAL); - - qdev_alias_all_properties(DEVICE(&smm->serial), o); -} - -static Property serial_mm_properties[] =3D { - /* - * Set the spacing between adjacent memory-mapped UART registers. - * Each register will be at (1 << regshift) bytes after the - * previous one. - */ - DEFINE_PROP_UINT8("regshift", SerialMM, regshift, 0), - DEFINE_PROP_UINT8("endianness", SerialMM, endianness, DEVICE_NATIVE_EN= DIAN), - DEFINE_PROP_END_OF_LIST(), -}; - -static void serial_mm_class_init(ObjectClass *oc, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(oc); - - device_class_set_props(dc, serial_mm_properties); - dc->realize =3D serial_mm_realize; - dc->vmsd =3D &vmstate_serial_mm; -} - -static const TypeInfo serial_mm_info =3D { - .name =3D TYPE_SERIAL_MM, - .parent =3D TYPE_SYS_BUS_DEVICE, - .class_init =3D serial_mm_class_init, - .instance_init =3D serial_mm_instance_init, - .instance_size =3D sizeof(SerialMM), -}; - static void serial_register_types(void) { type_register_static(&serial_info); - type_register_static(&serial_mm_info); } =20 type_init(serial_register_types) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 73e80d67de6..38d005c1682 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -29,7 +29,7 @@ #include "qemu/log.h" #include "qemu/module.h" #include "hw/usb/hcd-ohci.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "ui/console.h" #include "hw/sysbus.h" #include "migration/vmstate.h" diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 8259fe2e388..a31dc32a9f7 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -17,7 +17,7 @@ #include "sysemu/runstate.h" #include "hw/rtc/mc146818rtc.h" #include "hw/timer/i8254.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/char/parallel.h" #include "hw/intc/i8259.h" #include "hw/input/lasips2.h" diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 75980b6e3c7..ddd886f69ba 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -9,7 +9,7 @@ #include "qemu/datadir.h" #include "qapi/error.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" #include "sysemu/sysemu.h" diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_= ml605_mmu.c index 0f5fabc32e3..b4183c5267d 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -34,7 +34,7 @@ #include "hw/block/flash.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/qdev-properties.h" #include "exec/address-spaces.h" #include "hw/ssi/ssi.h" diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 1b44fb354c4..1ced1e337aa 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -22,7 +22,7 @@ =20 #include "elf.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/ide/pci.h" #include "hw/ide/ahci-pci.h" #include "hw/loader.h" diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 0d44e197078..33ce51fb09c 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -28,7 +28,7 @@ #include "hw/mips/mips.h" #include "hw/intc/i8259.h" #include "hw/dma/i8257.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/char/parallel.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 2067b4fecb5..a2db98665df 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -29,7 +29,7 @@ #include "qemu/datadir.h" #include "qapi/error.h" #include "elf.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/intc/loongson_liointc.h" #include "hw/mips/mips.h" #include "hw/mips/fw_cfg.h" diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 664a2ae0a9e..1df00c4bf99 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -31,7 +31,7 @@ #include "hw/clock.h" #include "hw/southbridge/piix.h" #include "hw/isa/superio.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "net/net.h" #include "hw/boards.h" #include "hw/i2c/smbus_eeprom.h" diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index 9170d6c474b..a07732d3dc5 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -31,7 +31,7 @@ #include "exec/address-spaces.h" #include "hw/clock.h" #include "hw/mips/mips.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index bffd6f721f7..9fb63515ef1 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -24,7 +24,7 @@ #include "cpu.h" #include "hw/irq.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "net/net.h" #include "hw/openrisc/boot.h" #include "hw/qdev-properties.h" diff --git a/hw/openrisc/virt.c b/hw/openrisc/virt.c index f8a68a6a6b1..47d2c9bd3c7 100644 --- a/hw/openrisc/virt.c +++ b/hw/openrisc/virt.c @@ -14,7 +14,7 @@ #include "exec/address-spaces.h" #include "hw/irq.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/core/split-irq.h" #include "hw/openrisc/boot.h" #include "hw/misc/sifive_test.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 3bd12b54ab9..b760c6d6a25 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -24,7 +24,7 @@ #include "net/net.h" #include "qemu/config-file.h" #include "hw/block/flash.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/pci/pci.h" #include "sysemu/block-backend-io.h" #include "sysemu/sysemu.h" diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c index 5f0e2333c0b..58cbd0507ab 100644 --- a/hw/ppc/ppc405_uc.c +++ b/hw/ppc/ppc405_uc.c @@ -32,7 +32,7 @@ #include "hw/irq.h" #include "hw/qdev-properties.h" #include "ppc405.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "qemu/timer.h" #include "sysemu/reset.h" #include "sysemu/sysemu.h" diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 73f80cf7065..96d9ce65c26 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -23,7 +23,7 @@ #include "sysemu/device_tree.h" #include "hw/loader.h" #include "elf.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/ppc/ppc.h" #include "hw/pci-host/ppc4xx.h" #include "sysemu/sysemu.h" diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 8dc75fb9f08..1fce093ac8a 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -31,7 +31,7 @@ #include "sysemu/sysemu.h" #include "sysemu/reset.h" #include "hw/sysbus.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/ide/pci.h" diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index c49da1f46f7..235281e9392 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -28,7 +28,7 @@ #include "exec/page-protection.h" #include "cpu.h" #include "hw/sysbus.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/block/flash.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index cef41c150aa..105c20a5ff9 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -27,7 +27,7 @@ #include "hw/loader.h" #include "hw/sysbus.h" #include "hw/qdev-properties.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "target/riscv/cpu.h" #include "hw/core/sysbus-fdt.h" #include "target/riscv/pmu.h" diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c index ab3c4ec3463..67ec403e1d4 100644 --- a/hw/sparc64/niagara.c +++ b/hw/sparc64/niagara.c @@ -27,7 +27,7 @@ #include "qemu/units.h" #include "cpu.h" #include "hw/boards.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "hw/misc/unimp.h" #include "hw/loader.h" #include "hw/sparc/sparc64.h" diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index a839abbf5d0..541c7f74fa0 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -34,8 +34,8 @@ #include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" #include "hw/pci-host/sabre.h" -#include "hw/char/serial.h" #include "hw/char/serial-isa.h" +#include "hw/char/serial-mm.h" #include "hw/char/parallel-isa.h" #include "hw/rtc/m48t59.h" #include "migration/vmstate.h" diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 955e8867a36..45b29d3b4e8 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -35,7 +35,7 @@ #include "hw/qdev-properties.h" #include "elf.h" #include "exec/memory.h" -#include "hw/char/serial.h" +#include "hw/char/serial-mm.h" #include "net/net.h" #include "hw/sysbus.h" #include "hw/block/flash.h" diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 1ad60da7aa2..ecde52f4a4a 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -136,7 +136,7 @@ config MUSICPAL select MARVELL_88W8618 select PTIMER select PFLASH_CFI02 - select SERIAL + select SERIAL_MM select WM8750 =20 config NETDUINO2 @@ -179,13 +179,13 @@ config OMAP select NAND select PFLASH_CFI01 select SD - select SERIAL + select SERIAL_MM =20 config PXA2XX bool select FRAMEBUFFER select I2C - select SERIAL + select SERIAL_MM select SD select SSI select USB_OHCI_SYSBUS @@ -399,7 +399,7 @@ config ALLWINNER_A10 select ALLWINNER_EMAC select ALLWINNER_I2C select AXP2XX_PMU - select SERIAL + select SERIAL_MM select UNIMP select USB_OHCI_SYSBUS =20 @@ -411,7 +411,7 @@ config ALLWINNER_H3 select ALLWINNER_SUN8I_EMAC select ALLWINNER_I2C select ALLWINNER_WDT - select SERIAL + select SERIAL_MM select ARM_TIMER select ARM_GIC select UNIMP @@ -427,7 +427,7 @@ config ALLWINNER_R40 select ALLWINNER_A10_PIT select ALLWINNER_WDT select AXP2XX_PMU - select SERIAL + select SERIAL_MM select ARM_TIMER select ARM_GIC select UNIMP @@ -542,7 +542,7 @@ config NPCM7XX select ISL_PMBUS_VR select PL310 # cache controller select PMBUS - select SERIAL + select SERIAL_MM select SSI select UNIMP select PCA954X @@ -564,7 +564,7 @@ config FSL_IMX31 default y depends on TCG && ARM imply I2C_DEVICES - select SERIAL + select SERIAL_MM select IMX select IMX_I2C select WDT_IMX2 @@ -593,7 +593,7 @@ config ASPEED_SOC select I2C select DPS310 select PCA9552 - select SERIAL + select SERIAL_MM select SMBUS_EEPROM select PCA954X select SSI @@ -681,7 +681,7 @@ config MSF2 bool select ARM_V7M select PTIMER - select SERIAL + select SERIAL_MM select SSI select UNIMP =20 diff --git a/hw/char/Kconfig b/hw/char/Kconfig index 4fd74ea8788..4b73a803bf3 100644 --- a/hw/char/Kconfig +++ b/hw/char/Kconfig @@ -21,6 +21,10 @@ config SERIAL_ISA depends on ISA_BUS select SERIAL =20 +config SERIAL_MM + bool + select SERIAL + config SERIAL_PCI bool default y if PCI_DEVICES diff --git a/hw/char/meson.build b/hw/char/meson.build index a4c4c5ff0f7..1750834385a 100644 --- a/hw/char/meson.build +++ b/hw/char/meson.build @@ -13,6 +13,7 @@ system_ss.add(when: 'CONFIG_PL011', if_true: files('pl011= .c')) system_ss.add(when: 'CONFIG_SCLPCONSOLE', if_true: files('sclpconsole.c', = 'sclpconsole-lm.c')) system_ss.add(when: 'CONFIG_SERIAL', if_true: files('serial.c')) system_ss.add(when: 'CONFIG_SERIAL_ISA', if_true: files('serial-isa.c')) +system_ss.add(when: 'CONFIG_SERIAL_MM', if_true: files('serial-mm.c')) system_ss.add(when: 'CONFIG_SERIAL_PCI', if_true: files('serial-pci.c')) system_ss.add(when: 'CONFIG_SERIAL_PCI_MULTI', if_true: files('serial-pci-= multi.c')) system_ss.add(when: 'CONFIG_SHAKTI_UART', if_true: files('shakti_uart.c')) diff --git a/hw/display/Kconfig b/hw/display/Kconfig index a4552c8ed78..5fde4855e3f 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -76,7 +76,7 @@ config SM501 bool select I2C select DDC - select SERIAL + select SERIAL_MM select USB_OHCI_SYSBUS =20 config TCX diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index d4d457f4ab4..9312c4294a4 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -9,7 +9,7 @@ config HPPA_B160L select ASTRO select DINO select LASI - select SERIAL + select SERIAL_MM select SERIAL_PCI select ISA_BUS select I8259 diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index 9c69170968c..fe1c6feac13 100644 --- a/hw/loongarch/Kconfig +++ b/hw/loongarch/Kconfig @@ -8,7 +8,7 @@ config LOONGARCH_VIRT imply PCI_DEVICES imply NVDIMM imply TPM_TIS_SYSBUS - select SERIAL + select SERIAL_MM select VIRTIO_PCI select PLATFORM_BUS select LOONGARCH_IPI diff --git a/hw/microblaze/Kconfig b/hw/microblaze/Kconfig index d78ba843fac..b0214b2c8b2 100644 --- a/hw/microblaze/Kconfig +++ b/hw/microblaze/Kconfig @@ -13,7 +13,7 @@ config PETALOGIX_ML605 default y depends on MICROBLAZE select PFLASH_CFI01 - select SERIAL + select SERIAL_MM select SSI_M25P80 select XILINX select XILINX_AXI diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig index 692bede538e..b09c89a0175 100644 --- a/hw/mips/Kconfig +++ b/hw/mips/Kconfig @@ -10,14 +10,14 @@ config MALTA select MIPS_CPS select PIIX select PFLASH_CFI01 - select SERIAL + select SERIAL_MM select SMBUS_EEPROM =20 config MIPSSIM bool default y depends on MIPS - select SERIAL + select SERIAL_MM select MIPSNET =20 config JAZZ @@ -37,7 +37,7 @@ config JAZZ select FDC_SYSBUS select MC146818RTC select PCKBD - select SERIAL + select SERIAL_MM select PARALLEL select DS1225Y select JAZZ_LED @@ -65,7 +65,7 @@ config LOONGSON3V imply VIRTIO_VGA imply QXL if SPICE imply USB_OHCI_PCI - select SERIAL + select SERIAL_MM select GOLDFISH_RTC select LOONGSON_IPI select LOONGSON_LIOINTC @@ -89,7 +89,7 @@ config MIPS_BOSTON select MIPS_CPS select PCI_EXPRESS_XILINX select AHCI_ICH9 - select SERIAL + select SERIAL_MM =20 config FW_CFG_MIPS bool diff --git a/hw/openrisc/Kconfig b/hw/openrisc/Kconfig index 76b953c62c2..0702f622a55 100644 --- a/hw/openrisc/Kconfig +++ b/hw/openrisc/Kconfig @@ -3,7 +3,7 @@ config OR1K_SIM default y depends on OPENRISC select DEVICE_TREE - select SERIAL + select SERIAL_MM select OPENCORES_ETH select OMPIC select SPLIT_IRQ @@ -19,6 +19,6 @@ config OR1K_VIRT select PCI select PCI_EXPRESS_GENERIC_BRIDGE select GOLDFISH_RTC - select SERIAL + select SERIAL_MM select SIFIVE_TEST select VIRTIO_MMIO diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 5addad11240..b44d91bebb2 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -51,7 +51,7 @@ config PPC405 select M48T59 select PFLASH_CFI02 select PPC4XX - select SERIAL + select SERIAL_MM =20 config PPC440 bool @@ -63,7 +63,7 @@ config PPC440 select PCI_EXPRESS select PPC440_PCIX select PPC4XX - select SERIAL + select SERIAL_MM select FDT_PPC =20 config PPC4XX @@ -80,7 +80,7 @@ config SAM460EX select IDE_SII3112 select M41T80 select PPC440 - select SERIAL + select SERIAL_MM select SM501 select SMBUS_EEPROM select USB_EHCI_SYSBUS @@ -163,7 +163,7 @@ config E500 select PLATFORM_BUS select PPCE500_PCI select SDHCI - select SERIAL + select SERIAL_MM select MPC_I2C select FDT_PPC select DS1338 @@ -187,7 +187,7 @@ config VIRTEX depends on PPC && FDT select PPC4XX select PFLASH_CFI01 - select SERIAL + select SERIAL_MM select XILINX select XILINX_ETHLITE select FDT_PPC diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index a2030e3a6ff..44695ff9f2c 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -44,7 +44,7 @@ config RISCV_VIRT select PCI select PCI_EXPRESS_GENERIC_BRIDGE select PFLASH_CFI01 - select SERIAL + select SERIAL_MM select RISCV_ACLINT select RISCV_APLIC select RISCV_IMSIC diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig index 3b948a22907..f764c8a219d 100644 --- a/hw/sparc64/Kconfig +++ b/hw/sparc64/Kconfig @@ -10,6 +10,7 @@ config SUN4U select ISA_BUS select FDC_ISA select SERIAL_ISA + select SERIAL_MM select PCI_SABRE select IDE_CMD646 select PCKBD diff --git a/hw/xtensa/Kconfig b/hw/xtensa/Kconfig index fc5c785cfac..1f0492d89c0 100644 --- a/hw/xtensa/Kconfig +++ b/hw/xtensa/Kconfig @@ -18,4 +18,4 @@ config XTENSA_XTFPGA select DEVICE_TREE select OPENCORES_ETH select PFLASH_CFI01 - select SERIAL + select SERIAL_MM --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060221; cv=none; d=zohomail.com; s=zohoarc; b=JVopyNDi85Ckl87YrGN5ayIyFlISXzEIje9VDknVK8P6FQEIZC6ek9WVrGRr7WgPbp9xsjoHBBpmSVVP36admUY7HrNOLgG+N5659YQhG63t6jO4v6sd4u565r6Gw8f/OozUO70jJKQt8yvFQRf/RCFY46AmKAEcvCAsV1MNvRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060221; 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=8znjZHEvrV04Wj1/EqjMfQ09PCfHPCGWYsDccur0vxQ=; b=f9lD+CGhHgLewhAL5ghleTGs8RiTs4Vrm2LhK6dhqo0OEHYB+TRxroXqiMWcI+R+6+hLmZwfFKZtPTfMbF9+yg+6sYtHzZHSboPUa1Hp1zhAuAADDrdGCrmXkl5qNMkCTaAlxkgnGiu3os+fyWjMXxbH0OcweBIafaYAVo07O8U= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060221300503.16069530305674; Fri, 4 Oct 2024 09:43:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlJC-00054W-24; Fri, 04 Oct 2024 12:37: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 1swlH1-0008Jp-2B for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:23 -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 1swlGw-0006RW-4G for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:22 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-361-gPVw8TCBMeOOOwECE6Povg-1; Fri, 04 Oct 2024 12:35:13 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42cb998fd32so15873395e9.1 for ; Fri, 04 Oct 2024 09:35:12 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d16972b2esm23767f8f.105.2024.10.04.09.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059717; 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=8znjZHEvrV04Wj1/EqjMfQ09PCfHPCGWYsDccur0vxQ=; b=DbYLBRTp4LPNZ/v1mMIZ5A2ySeGQqgYgGFsRPPAb72/a3o3hUHoZ65cyGKcUoI6zxihTuX Mvazz0O+M4rCyhRqeGn8+JD9evF0JKE5yXpJsLtZxVdXJcK//fzYtdmQ+xBiap0ZD1rqgS cr7AlAVC0Qi8KNDrpWbhnxnK/L7EDvw= X-MC-Unique: gPVw8TCBMeOOOwECE6Povg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059711; x=1728664511; 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=8znjZHEvrV04Wj1/EqjMfQ09PCfHPCGWYsDccur0vxQ=; b=Ub3osLeWeI2X7/JJWt5WQ0D2uAEOrmg8JIYVH9ablPqBS9+P2kuMCTBj0awizVo2M3 ZLJcnfGA1VdI8YNMoRmPqTpM+kI0qN4qHPaDLb2fYsEFm+pu4L0kFPJQiZAF2Ed5+Nwq 3YzL0RjFGdbnwis0bwxqBXgbUSZigy4mwGfHhddV53nu6P8u7ILHMIt7xYkcKYO7ykYA xrKL05jiJyJqKDFTnsUfNcI0xc3eezMu4rAGS9XdcjEqrPA/8bO3ZXS0ZrCPMiSpnRzt ohQJtRdm6ZrNtOXUmWNziHBcv5vS2SWK/dZljAMKLZB489QS7+SxNuc3+7xd3nWU3Cvm ZdBQ== X-Gm-Message-State: AOJu0YxPAHXIX5m56sknTYng/uyl9M938F9hedB9DbmCZPX70xeXCraA t4NrIFl3W6bycOge5ArDTIuR+xtnqtsYpfNeFA1LjRFSxb85dusV5nu/uPFSEBOGiMj6Xce6KZd Xi2VXBLyKDxfhzfpHmFH7jSMq5LW81ke5xNSsRUYopVPCHN+2VIy3WzbeIj/uDRjgxRpAU7Sqlm TMdl9kbBhR6G/7u7WddlxgqDPSJ5nYRNogUhu4hnA= X-Received: by 2002:a05:600c:4ec7:b0:42c:b9dd:93ee with SMTP id 5b1f17b1804b1-42f85af8d63mr29113235e9.34.1728059709552; Fri, 04 Oct 2024 09:35:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGu6jEM6UqJ4H9kfjrx/VSm7uEio9seq3x9copyGUyHyLgekNBEX7qcLluDnhRuyTGYIB8LdQ== X-Received: by 2002:a05:600c:4ec7:b0:42c:b9dd:93ee with SMTP id 5b1f17b1804b1-42f85af8d63mr29112345e9.34.1728059707818; Fri, 04 Oct 2024 09:35:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Greg Kurz Subject: [PULL 16/23] 9p: remove 'proxy' filesystem backend driver Date: Fri, 4 Oct 2024 18:34:08 +0200 Message-ID: <20241004163415.951106-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060222359116600 Content-Type: text/plain; charset="utf-8" It has been deprecated since 8.1; remove it and suggest using the 'local' f= ile system backend driver instead or virtiofsd. Acked-by: Greg Kurz Signed-off-by: Paolo Bonzini --- MAINTAINERS | 8 - docs/about/deprecated.rst | 22 - docs/about/removed-features.rst | 14 + docs/conf.py | 3 - docs/meson.build | 1 - docs/tools/index.rst | 1 - docs/tools/virtfs-proxy-helper.rst | 75 -- meson.build | 8 - fsdev/qemu-fsdev.h | 1 - hw/9pfs/9p-proxy.h | 101 --- fsdev/qemu-fsdev.c | 19 - fsdev/virtfs-proxy-helper.c | 1193 -------------------------- hw/9pfs/9p-proxy.c | 1279 ---------------------------- fsdev/meson.build | 8 - hw/9pfs/meson.build | 1 - meson_options.txt | 2 - qemu-options.hx | 46 - scripts/meson-buildoptions. | 0 scripts/meson-buildoptions.sh | 4 - 19 files changed, 14 insertions(+), 2772 deletions(-) delete mode 100644 docs/tools/virtfs-proxy-helper.rst delete mode 100644 hw/9pfs/9p-proxy.h delete mode 100644 fsdev/virtfs-proxy-helper.c delete mode 100644 hw/9pfs/9p-proxy.c create mode 100644 scripts/meson-buildoptions. diff --git a/MAINTAINERS b/MAINTAINERS index 62f5255f409..5720f809720 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2258,20 +2258,12 @@ S: Maintained W: https://wiki.qemu.org/Documentation/9p F: hw/9pfs/ X: hw/9pfs/xen-9p* -X: hw/9pfs/9p-proxy* F: fsdev/ -X: fsdev/virtfs-proxy-helper.c F: tests/qtest/virtio-9p-test.c F: tests/qtest/libqos/virtio-9p* T: git https://gitlab.com/gkurz/qemu.git 9p-next T: git https://github.com/cschoenebeck/qemu.git 9p.next =20 -virtio-9p-proxy -F: hw/9pfs/9p-proxy* -F: fsdev/virtfs-proxy-helper.c -F: docs/tools/virtfs-proxy-helper.rst -S: Obsolete - virtio-blk M: Stefan Hajnoczi L: qemu-block@nongnu.org diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index c0aa52def58..33a8c371cf8 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -329,28 +329,6 @@ the addition of volatile memory support, it is now nec= essary to distinguish between persistent and volatile memory backends. As such, memdev is depre= cated in favor of persistent-memdev. =20 -``-fsdev proxy`` and ``-virtfs proxy`` (since 8.1) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The 9p ``proxy`` filesystem backend driver has been deprecated and will be -removed (along with its proxy helper daemon) in a future version of QEMU. = Please -use ``-fsdev local`` or ``-virtfs local`` for using the 9p ``local`` files= ystem -backend, or alternatively consider deploying virtiofsd instead. - -The 9p ``proxy`` backend was originally developed as an alternative to the= 9p -``local`` backend. The idea was to enhance security by dispatching actual = low -level filesystem operations from 9p server (QEMU process) over to a separa= te -process (the virtfs-proxy-helper binary). However this alternative never g= ained -momentum. The proxy backend is much slower than the local backend, hasn't = seen -any development in years, and showed to be less secure, especially due to = the -fact that its helper daemon must be run as root, whereas with the local ba= ckend -QEMU is typically run as unprivileged user and allows to tighten behaviour= by -mapping permissions et al by using its 'mapped' security model option. - -Nowadays it would make sense to reimplement the ``proxy`` backend by using -QEMU's ``vhost`` feature, which would eliminate the high latency costs und= er -which the 9p ``proxy`` backend currently suffers. However as of to date no= body -has indicated plans for such kind of reimplementation unfortunately. =20 RISC-V CPU properties which start with capital 'Z' (since 8.2) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 06f8cc1b739..cc1a5d2d196 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -517,6 +517,20 @@ The virtio-blk SCSI passthrough feature is a legacy VI= RTIO feature. VIRTIO 1.0 and later do not support it because the virtio-scsi device was introduced = for full SCSI support. Use virtio-scsi instead when SCSI passthrough is requi= red. =20 +``-fsdev proxy`` and ``-virtfs proxy`` (since 9.2) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The 9p ``proxy`` filesystem backend driver was originally developed to +enhance security by dispatching low level filesystem operations from 9p +server (QEMU process) over to a separate process (the virtfs-proxy-helper +binary). However the proxy backend was much slower than the local backend, +didn't see any development in years, and showed to be less secure, +especially due to the fact that its helper daemon must be run as root. + +Use ``local``, possibly mapping permissions et al by using its 'mapped' +security model option, or switch to ``virtiofs``. The virtiofs daemon +``virtiofsd`` uses vhost to eliminate the high latency costs of the 9p +``proxy`` backend. =20 User-mode emulator command line arguments ----------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index 876f6768815..c11a6ead8a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -275,9 +275,6 @@ ('tools/qemu-trace-stap', 'qemu-trace-stap', 'QEMU SystemTap trace tool', [], 1), - ('tools/virtfs-proxy-helper', 'virtfs-proxy-helper', - 'QEMU 9p virtfs proxy filesystem helper', - ['M. Mohan Kumar'], 1), ] man_make_section_directory =3D False =20 diff --git a/docs/meson.build b/docs/meson.build index 322452c8778..3676f81c4d3 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -54,7 +54,6 @@ if build_docs 'qemu-pr-helper.8': (have_tools ? 'man8' : ''), 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''), 'qemu-trace-stap.1': (stap.found() ? 'man1' : ''), - 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''), 'qemu.1': 'man1', 'qemu-block-drivers.7': 'man7', 'qemu-cpu-models.7': 'man7' diff --git a/docs/tools/index.rst b/docs/tools/index.rst index 33ad438e86f..1e88ae48cdc 100644 --- a/docs/tools/index.rst +++ b/docs/tools/index.rst @@ -15,5 +15,4 @@ command line utilities and other standalone programs. qemu-nbd qemu-pr-helper qemu-trace-stap - virtfs-proxy-helper qemu-vmsr-helper diff --git a/docs/tools/virtfs-proxy-helper.rst b/docs/tools/virtfs-proxy-h= elper.rst deleted file mode 100644 index bd310ebb07b..00000000000 --- a/docs/tools/virtfs-proxy-helper.rst +++ /dev/null @@ -1,75 +0,0 @@ -QEMU 9p virtfs proxy filesystem helper -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -Synopsis --------- - -**virtfs-proxy-helper** [*OPTIONS*] - -Description ------------ - -NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be -removed, along with this daemon, in a future version of QEMU! - -Pass-through security model in QEMU 9p server needs root privilege to do -few file operations (like chown, chmod to any mode/uid:gid). There are two -issues in pass-through security model: - -- TOCTTOU vulnerability: Following symbolic links in the server could - provide access to files beyond 9p export path. - -- Running QEMU with root privilege could be a security issue. - -To overcome above issues, following approach is used: A new filesystem -type 'proxy' is introduced. Proxy FS uses chroot + socket combination -for securing the vulnerability known with following symbolic links. -Intention of adding a new filesystem type is to allow qemu to run -in non-root mode, but doing privileged operations using socket IO. - -Proxy helper (a stand alone binary part of qemu) is invoked with -root privileges. Proxy helper chroots into 9p export path and creates -a socket pair or a named socket based on the command line parameter. -QEMU and proxy helper communicate using this socket. QEMU proxy fs -driver sends filesystem request to proxy helper and receives the -response from it. - -The proxy helper is designed so that it can drop root privileges except -for the capabilities needed for doing filesystem operations. - -Options -------- - -The following options are supported: - -.. program:: virtfs-proxy-helper - -.. option:: -h - - Display help and exit - -.. option:: -p, --path PATH - - Path to export for proxy filesystem driver - -.. option:: -f, --fd SOCKET_ID - - Use given file descriptor as socket descriptor for communicating with - qemu proxy fs drier. Usually a helper like libvirt will create - socketpair and pass one of the fds as parameter to this option. - -.. option:: -s, --socket SOCKET_FILE - - Creates named socket file for communicating with qemu proxy fs driver - -.. option:: -u, --uid UID - - uid to give access to named socket file; used in combination with -g. - -.. option:: -g, --gid GID - - gid to give access to named socket file; used in combination with -u. - -.. option:: -n, --nodaemon - - Run as a normal program. By default program will run in daemon mode diff --git a/meson.build b/meson.build index 10464466ff3..67d045eb5af 100644 --- a/meson.build +++ b/meson.build @@ -2219,13 +2219,6 @@ have_virtfs =3D get_option('virtfs') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() =20 -have_virtfs_proxy_helper =3D get_option('virtfs_proxy_helper') \ - .require(host_os !=3D 'darwin', error_message: 'the virtfs proxy helpe= r is incompatible with macOS') \ - .require(have_virtfs, error_message: 'the virtfs proxy helper requires= that virtfs is enabled') \ - .disable_auto_if(not have_tools) \ - .require(libcap_ng.found(), error_message: 'the virtfs proxy helper re= quires libcap-ng') \ - .allowed() - qga_fsfreeze =3D false qga_fstrim =3D false if host_os =3D=3D 'linux' @@ -4420,7 +4413,6 @@ if have_block summary_info +=3D {'Block whitelist (ro)': get_option('block_drv_ro_whit= elist')} summary_info +=3D {'Use block whitelist in tools': get_option('block_drv= _whitelist_in_tools')} summary_info +=3D {'VirtFS (9P) support': have_virtfs} - summary_info +=3D {'VirtFS (9P) Proxy Helper support (deprecated)': have= _virtfs_proxy_helper} summary_info +=3D {'replication support': config_host_data.get('CONFIG_R= EPLICATION')} summary_info +=3D {'bochs support': get_option('bochs').allowed()} summary_info +=3D {'cloop support': get_option('cloop').allowed()} diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index 52a53977701..731f1406a81 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -18,5 +18,4 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp); FsDriverEntry *get_fsdev_fsentry(char *id); extern FileOperations local_ops; extern FileOperations synth_ops; -extern FileOperations proxy_ops; #endif diff --git a/hw/9pfs/9p-proxy.h b/hw/9pfs/9p-proxy.h deleted file mode 100644 index 9be4718d3e2..00000000000 --- a/hw/9pfs/9p-proxy.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 9p Proxy callback - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * M. Mohan Kumar - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -/* - * NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be - * removed in a future version of QEMU! - */ - -#ifndef QEMU_9P_PROXY_H -#define QEMU_9P_PROXY_H - -#define PROXY_MAX_IO_SZ (64 * 1024) -#define V9FS_FD_VALID INT_MAX - -/* - * proxy iovec only support one element and - * marsha/unmarshal doesn't do little endian conversion. - */ -#define proxy_unmarshal(in_sg, offset, fmt, args...) \ - v9fs_iov_unmarshal(in_sg, 1, offset, 0, fmt, ##args) -#define proxy_marshal(out_sg, offset, fmt, args...) \ - v9fs_iov_marshal(out_sg, 1, offset, 0, fmt, ##args) - -union MsgControl { - struct cmsghdr cmsg; - char control[CMSG_SPACE(sizeof(int))]; -}; - -typedef struct { - uint32_t type; - uint32_t size; -} ProxyHeader; - -#define PROXY_HDR_SZ (sizeof(ProxyHeader)) - -enum { - T_SUCCESS =3D 0, - T_ERROR, - T_OPEN, - T_CREATE, - T_MKNOD, - T_MKDIR, - T_SYMLINK, - T_LINK, - T_LSTAT, - T_READLINK, - T_STATFS, - T_CHMOD, - T_CHOWN, - T_TRUNCATE, - T_UTIME, - T_RENAME, - T_REMOVE, - T_LGETXATTR, - T_LLISTXATTR, - T_LSETXATTR, - T_LREMOVEXATTR, - T_GETVERSION, -}; - -typedef struct { - uint64_t st_dev; - uint64_t st_ino; - uint64_t st_nlink; - uint32_t st_mode; - uint32_t st_uid; - uint32_t st_gid; - uint64_t st_rdev; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_atim_sec; - uint64_t st_atim_nsec; - uint64_t st_mtim_sec; - uint64_t st_mtim_nsec; - uint64_t st_ctim_sec; - uint64_t st_ctim_nsec; -} ProxyStat; - -typedef struct { - uint64_t f_type; - uint64_t f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_fsid[2]; - uint64_t f_namelen; - uint64_t f_frsize; -} ProxyStatFS; -#endif diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index f5c953a7105..57877dad0a7 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -89,17 +89,6 @@ static FsDriverTable FsDrivers[] =3D { NULL }, }, - { - .name =3D "proxy", - .ops =3D &proxy_ops, - .opts =3D (const char * []) { - COMMON_FS_DRIVER_OPTIONS, - "socket", - "sock_fd", - "writeout", - NULL - }, - }, }; =20 static int validate_opt(void *opaque, const char *name, const char *value, @@ -133,14 +122,6 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp) } =20 if (fsdriver) { - if (strncmp(fsdriver, "proxy", 5) =3D=3D 0) { - warn_report( - "'-fsdev proxy' and '-virtfs proxy' are deprecated, use " - "'local' instead of 'proxy, or consider deploying virtiofs= d " - "as alternative to 9p" - ); - } - for (i =3D 0; i < ARRAY_SIZE(FsDrivers); i++) { if (strcmp(FsDrivers[i].name, fsdriver) =3D=3D 0) { break; diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c deleted file mode 100644 index 144aaf585ad..00000000000 --- a/fsdev/virtfs-proxy-helper.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* - * Helper for QEMU Proxy FS Driver - * Copyright IBM, Corp. 2011 - * - * Authors: - * M. Mohan Kumar - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -/* - * NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be - * removed in a future version of QEMU! - */ - -#include "qemu/osdep.h" -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_LINUX_MAGIC_H -#include -#endif -#include -#include "qemu/sockets.h" -#include "qemu/xattr.h" -#include "9p-iov-marshal.h" -#include "hw/9pfs/9p-proxy.h" -#include "hw/9pfs/9p-util.h" -#include "fsdev/9p-iov-marshal.h" - -#define PROGNAME "virtfs-proxy-helper" - -#ifndef XFS_SUPER_MAGIC -#define XFS_SUPER_MAGIC 0x58465342 -#endif -#ifndef EXT2_SUPER_MAGIC -#define EXT2_SUPER_MAGIC 0xEF53 -#endif -#ifndef REISERFS_SUPER_MAGIC -#define REISERFS_SUPER_MAGIC 0x52654973 -#endif -#ifndef BTRFS_SUPER_MAGIC -#define BTRFS_SUPER_MAGIC 0x9123683E -#endif - -static const struct option helper_opts[] =3D { - {"fd", required_argument, NULL, 'f'}, - {"path", required_argument, NULL, 'p'}, - {"nodaemon", no_argument, NULL, 'n'}, - {"socket", required_argument, NULL, 's'}, - {"uid", required_argument, NULL, 'u'}, - {"gid", required_argument, NULL, 'g'}, - {}, -}; - -static bool is_daemon; -static bool get_version; /* IOC getversion IOCTL supported */ -static char *prog_name; - -static void G_GNUC_PRINTF(2, 3) do_log(int loglevel, const char *format, .= ..) -{ - va_list ap; - - va_start(ap, format); - if (is_daemon) { - vsyslog(LOG_CRIT, format, ap); - } else { - vfprintf(stderr, format, ap); - } - va_end(ap); -} - -static void do_perror(const char *string) -{ - if (is_daemon) { - syslog(LOG_CRIT, "%s:%s", string, strerror(errno)); - } else { - fprintf(stderr, "%s:%s\n", string, strerror(errno)); - } -} - -static int init_capabilities(void) -{ - /* helper needs following capabilities only */ - int cap_list[] =3D { - CAP_CHOWN, - CAP_DAC_OVERRIDE, - CAP_FOWNER, - CAP_FSETID, - CAP_SETGID, - CAP_MKNOD, - CAP_SETUID, - }; - int i; - - capng_clear(CAPNG_SELECT_BOTH); - for (i =3D 0; i < ARRAY_SIZE(cap_list); i++) { - if (capng_update(CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, - cap_list[i]) < 0) { - do_perror("capng_update"); - return -1; - } - } - if (capng_apply(CAPNG_SELECT_BOTH) < 0) { - do_perror("capng_apply"); - return -1; - } - - /* Prepare effective set for setugid. */ - for (i =3D 0; i < ARRAY_SIZE(cap_list); i++) { - if (cap_list[i] =3D=3D CAP_DAC_OVERRIDE) { - continue; - } - - if (capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, - cap_list[i]) < 0) { - do_perror("capng_update"); - return -1; - } - } - return 0; -} - -static int socket_read(int sockfd, void *buff, ssize_t size) -{ - ssize_t retval, total =3D 0; - - while (size) { - retval =3D read(sockfd, buff, size); - if (retval =3D=3D 0) { - return -EIO; - } - if (retval < 0) { - if (errno =3D=3D EINTR) { - continue; - } - return -errno; - } - size -=3D retval; - buff +=3D retval; - total +=3D retval; - } - return total; -} - -static int socket_write(int sockfd, void *buff, ssize_t size) -{ - ssize_t retval, total =3D 0; - - while (size) { - retval =3D write(sockfd, buff, size); - if (retval < 0) { - if (errno =3D=3D EINTR) { - continue; - } - return -errno; - } - size -=3D retval; - buff +=3D retval; - total +=3D retval; - } - return total; -} - -static int read_request(int sockfd, struct iovec *iovec, ProxyHeader *head= er) -{ - int retval; - - /* - * read the request header. - */ - iovec->iov_len =3D 0; - retval =3D socket_read(sockfd, iovec->iov_base, PROXY_HDR_SZ); - if (retval < 0) { - return retval; - } - iovec->iov_len =3D PROXY_HDR_SZ; - retval =3D proxy_unmarshal(iovec, 0, "dd", &header->type, &header->siz= e); - if (retval < 0) { - return retval; - } - /* - * We can't process message.size > PROXY_MAX_IO_SZ. - * Treat it as fatal error - */ - if (header->size > PROXY_MAX_IO_SZ) { - return -ENOBUFS; - } - retval =3D socket_read(sockfd, iovec->iov_base + PROXY_HDR_SZ, header-= >size); - if (retval < 0) { - return retval; - } - iovec->iov_len +=3D header->size; - return 0; -} - -static int send_fd(int sockfd, int fd) -{ - struct msghdr msg; - struct iovec iov; - int retval, data; - struct cmsghdr *cmsg; - union MsgControl msg_control; - - iov.iov_base =3D &data; - iov.iov_len =3D sizeof(data); - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov =3D &iov; - msg.msg_iovlen =3D 1; - /* No ancillary data on error */ - if (fd < 0) { - /* fd is really negative errno if the request failed */ - data =3D fd; - } else { - data =3D V9FS_FD_VALID; - msg.msg_control =3D &msg_control; - msg.msg_controllen =3D sizeof(msg_control); - - cmsg =3D &msg_control.cmsg; - cmsg->cmsg_len =3D CMSG_LEN(sizeof(fd)); - cmsg->cmsg_level =3D SOL_SOCKET; - cmsg->cmsg_type =3D SCM_RIGHTS; - memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); - } - - do { - retval =3D sendmsg(sockfd, &msg, 0); - } while (retval < 0 && errno =3D=3D EINTR); - if (fd >=3D 0) { - close(fd); - } - if (retval < 0) { - return retval; - } - return 0; -} - -static int send_status(int sockfd, struct iovec *iovec, int status) -{ - ProxyHeader header; - int retval, msg_size; - - if (status < 0) { - header.type =3D T_ERROR; - } else { - header.type =3D T_SUCCESS; - } - header.size =3D sizeof(status); - /* - * marshal the return status. We don't check error. - * because we are sure we have enough space for the status - */ - msg_size =3D proxy_marshal(iovec, 0, "ddd", header.type, - header.size, status); - if (msg_size < 0) { - return msg_size; - } - retval =3D socket_write(sockfd, iovec->iov_base, msg_size); - if (retval < 0) { - return retval; - } - return 0; -} - -/* - * from man 7 capabilities, section - * Effect of User ID Changes on Capabilities: - * If the effective user ID is changed from nonzero to 0, then the permitt= ed - * set is copied to the effective set. If the effective user ID is changed - * from 0 to nonzero, then all capabilities are are cleared from the effec= tive - * set. - * - * The setfsuid/setfsgid man pages warn that changing the effective user I= D may - * expose the program to unwanted signals, but this is not true anymore: f= or an - * unprivileged (without CAP_KILL) program to send a signal, the real or - * effective user ID of the sending process must equal the real or saved u= ser - * ID of the target process. Even when dropping privileges, it is enough = to - * keep the saved UID to a "privileged" value and virtfs-proxy-helper won't - * be exposed to signals. So just use setresuid/setresgid. - */ -static int setugid(int uid, int gid, int *suid, int *sgid) -{ - int retval; - - *suid =3D geteuid(); - *sgid =3D getegid(); - - if (setresgid(-1, gid, *sgid) =3D=3D -1) { - return -errno; - } - - if (setresuid(-1, uid, *suid) =3D=3D -1) { - retval =3D -errno; - goto err_sgid; - } - - if (uid =3D=3D 0 && gid =3D=3D 0) { - /* Linux has already copied the permitted set to the effective set= . */ - return 0; - } - - /* - * All capabilities have been cleared from the effective set. However - * we still need DAC_OVERRIDE because we don't change supplementary - * group ids, and hence may be subject to DAC rules. init_capabilities - * left the set of capabilities that we want in libcap-ng's state. - */ - if (capng_apply(CAPNG_SELECT_CAPS) < 0) { - retval =3D -errno; - do_perror("capng_apply"); - goto err_suid; - } - return 0; - -err_suid: - if (setresuid(-1, *suid, *suid) =3D=3D -1) { - abort(); - } -err_sgid: - if (setresgid(-1, *sgid, *sgid) =3D=3D -1) { - abort(); - } - return retval; -} - -/* - * This is used to reset the ugid back with the saved values - * There is nothing much we can do checking error values here. - */ -static void resetugid(int suid, int sgid) -{ - if (setresgid(-1, sgid, sgid) =3D=3D -1) { - abort(); - } - if (setresuid(-1, suid, suid) =3D=3D -1) { - abort(); - } -} - -/* - * Open regular file or directory. Attempts to open any special file are - * rejected. - * - * returns file descriptor or -1 on error - */ -static int open_regular(const char *pathname, int flags, mode_t mode) -{ - int fd; - - fd =3D open(pathname, flags, mode); - if (fd < 0) { - return fd; - } - - if (close_if_special_file(fd) < 0) { - return -1; - } - - return fd; -} - -/* - * send response in two parts - * 1) ProxyHeader - * 2) Response or error status - * This function should be called with marshaled response - * send_response constructs header part and error part only. - * send response sends {ProxyHeader,Response} if the request was success - * otherwise sends {ProxyHeader,error status} - */ -static int send_response(int sock, struct iovec *iovec, int size) -{ - int retval; - ProxyHeader header; - - /* - * If response size exceeds available iovec->iov_len, - * we return ENOBUFS - */ - if (size > PROXY_MAX_IO_SZ) { - size =3D -ENOBUFS; - } - - if (size < 0) { - /* - * In case of error we would not have got the error encoded - * already so encode the error here. - */ - header.type =3D T_ERROR; - header.size =3D sizeof(size); - proxy_marshal(iovec, PROXY_HDR_SZ, "d", size); - } else { - header.type =3D T_SUCCESS; - header.size =3D size; - } - proxy_marshal(iovec, 0, "dd", header.type, header.size); - retval =3D socket_write(sock, iovec->iov_base, header.size + PROXY_HDR= _SZ); - if (retval < 0) { - return retval; - } - return 0; -} - -/* - * gets generation number - * returns -errno on failure and sizeof(generation number) on success - */ -static int do_getversion(struct iovec *iovec, struct iovec *out_iovec) -{ - uint64_t version; - int retval =3D -ENOTTY; -#ifdef FS_IOC_GETVERSION - int fd; - V9fsString path; -#endif - - - /* no need to issue ioctl */ - if (!get_version) { - version =3D 0; - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "q", version); - return retval; - } -#ifdef FS_IOC_GETVERSION - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "s", &path); - if (retval < 0) { - return retval; - } - - fd =3D open(path.data, O_RDONLY); - if (fd < 0) { - retval =3D -errno; - goto err_out; - } - if (ioctl(fd, FS_IOC_GETVERSION, &version) < 0) { - retval =3D -errno; - } else { - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "q", version); - } - close(fd); -err_out: - v9fs_string_free(&path); -#endif - return retval; -} - -static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_io= vec) -{ - int size =3D 0, offset, retval; - V9fsString path, name, xattr; - - v9fs_string_init(&xattr); - v9fs_string_init(&path); - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "ds", &size, &path); - if (retval < 0) { - return retval; - } - offset =3D PROXY_HDR_SZ + retval; - - if (size) { - xattr.data =3D g_malloc(size); - xattr.size =3D size; - } - switch (type) { - case T_LGETXATTR: - v9fs_string_init(&name); - retval =3D proxy_unmarshal(iovec, offset, "s", &name); - if (retval > 0) { - retval =3D lgetxattr(path.data, name.data, xattr.data, size); - if (retval < 0) { - retval =3D -errno; - } else { - xattr.size =3D retval; - } - } - v9fs_string_free(&name); - break; - case T_LLISTXATTR: - retval =3D llistxattr(path.data, xattr.data, size); - if (retval < 0) { - retval =3D -errno; - } else { - xattr.size =3D retval; - } - break; - } - if (retval < 0) { - goto err_out; - } - - if (!size) { - proxy_marshal(out_iovec, PROXY_HDR_SZ, "d", retval); - retval =3D sizeof(retval); - } else { - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &xattr); - } -err_out: - v9fs_string_free(&xattr); - v9fs_string_free(&path); - return retval; -} - -static void stat_to_prstat(ProxyStat *pr_stat, struct stat *stat) -{ - memset(pr_stat, 0, sizeof(*pr_stat)); - pr_stat->st_dev =3D stat->st_dev; - pr_stat->st_ino =3D stat->st_ino; - pr_stat->st_nlink =3D stat->st_nlink; - pr_stat->st_mode =3D stat->st_mode; - pr_stat->st_uid =3D stat->st_uid; - pr_stat->st_gid =3D stat->st_gid; - pr_stat->st_rdev =3D stat->st_rdev; - pr_stat->st_size =3D stat->st_size; - pr_stat->st_blksize =3D stat->st_blksize; - pr_stat->st_blocks =3D stat->st_blocks; - pr_stat->st_atim_sec =3D stat->st_atim.tv_sec; - pr_stat->st_atim_nsec =3D stat->st_atim.tv_nsec; - pr_stat->st_mtim_sec =3D stat->st_mtim.tv_sec; - pr_stat->st_mtim_nsec =3D stat->st_mtim.tv_nsec; - pr_stat->st_ctim_sec =3D stat->st_ctim.tv_sec; - pr_stat->st_ctim_nsec =3D stat->st_ctim.tv_nsec; -} - -static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, struct statfs *stfs) -{ - memset(pr_stfs, 0, sizeof(*pr_stfs)); - pr_stfs->f_type =3D stfs->f_type; - pr_stfs->f_bsize =3D stfs->f_bsize; - pr_stfs->f_blocks =3D stfs->f_blocks; - pr_stfs->f_bfree =3D stfs->f_bfree; - pr_stfs->f_bavail =3D stfs->f_bavail; - pr_stfs->f_files =3D stfs->f_files; - pr_stfs->f_ffree =3D stfs->f_ffree; - pr_stfs->f_fsid[0] =3D stfs->f_fsid.__val[0]; - pr_stfs->f_fsid[1] =3D stfs->f_fsid.__val[1]; - pr_stfs->f_namelen =3D stfs->f_namelen; - pr_stfs->f_frsize =3D stfs->f_frsize; -} - -/* - * Gets stat/statfs information and packs in out_iovec structure - * on success returns number of bytes packed in out_iovec structure - * otherwise returns -errno - */ -static int do_stat(int type, struct iovec *iovec, struct iovec *out_iovec) -{ - int retval; - V9fsString path; - ProxyStat pr_stat; - ProxyStatFS pr_stfs; - struct stat st_buf; - struct statfs stfs_buf; - - v9fs_string_init(&path); - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "s", &path); - if (retval < 0) { - return retval; - } - - switch (type) { - case T_LSTAT: - retval =3D lstat(path.data, &st_buf); - if (retval < 0) { - retval =3D -errno; - } else { - stat_to_prstat(&pr_stat, &st_buf); - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, - "qqqdddqqqqqqqqqq", pr_stat.st_dev, - pr_stat.st_ino, pr_stat.st_nlink, - pr_stat.st_mode, pr_stat.st_uid, - pr_stat.st_gid, pr_stat.st_rdev, - pr_stat.st_size, pr_stat.st_blksize, - pr_stat.st_blocks, - pr_stat.st_atim_sec, pr_stat.st_atim_ns= ec, - pr_stat.st_mtim_sec, pr_stat.st_mtim_ns= ec, - pr_stat.st_ctim_sec, pr_stat.st_ctim_ns= ec); - } - break; - case T_STATFS: - retval =3D statfs(path.data, &stfs_buf); - if (retval < 0) { - retval =3D -errno; - } else { - statfs_to_prstatfs(&pr_stfs, &stfs_buf); - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, - "qqqqqqqqqqq", pr_stfs.f_type, - pr_stfs.f_bsize, pr_stfs.f_blocks, - pr_stfs.f_bfree, pr_stfs.f_bavail, - pr_stfs.f_files, pr_stfs.f_ffree, - pr_stfs.f_fsid[0], pr_stfs.f_fsid[1], - pr_stfs.f_namelen, pr_stfs.f_frsize); - } - break; - } - v9fs_string_free(&path); - return retval; -} - -static int do_readlink(struct iovec *iovec, struct iovec *out_iovec) -{ - char *buffer; - int size, retval; - V9fsString target, path; - - v9fs_string_init(&path); - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &size); - if (retval < 0) { - v9fs_string_free(&path); - return retval; - } - buffer =3D g_malloc(size); - v9fs_string_init(&target); - retval =3D readlink(path.data, buffer, size - 1); - if (retval > 0) { - buffer[retval] =3D '\0'; - v9fs_string_sprintf(&target, "%s", buffer); - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &target); - } else { - retval =3D -errno; - } - g_free(buffer); - v9fs_string_free(&target); - v9fs_string_free(&path); - return retval; -} - -/* - * create other filesystem objects and send 0 on success - * return -errno on error - */ -static int do_create_others(int type, struct iovec *iovec) -{ - dev_t rdev; - int retval =3D 0; - int offset =3D PROXY_HDR_SZ; - V9fsString oldpath, path; - int mode, uid, gid, cur_uid, cur_gid; - - v9fs_string_init(&path); - v9fs_string_init(&oldpath); - - retval =3D proxy_unmarshal(iovec, offset, "dd", &uid, &gid); - if (retval < 0) { - return retval; - } - offset +=3D retval; - retval =3D setugid(uid, gid, &cur_uid, &cur_gid); - if (retval < 0) { - goto unmarshal_err_out; - } - switch (type) { - case T_MKNOD: - retval =3D proxy_unmarshal(iovec, offset, "sdq", &path, &mode, &rd= ev); - if (retval < 0) { - goto err_out; - } - retval =3D mknod(path.data, mode, rdev); - break; - case T_MKDIR: - retval =3D proxy_unmarshal(iovec, offset, "sd", &path, &mode); - if (retval < 0) { - goto err_out; - } - retval =3D g_mkdir(path.data, mode); - break; - case T_SYMLINK: - retval =3D proxy_unmarshal(iovec, offset, "ss", &oldpath, &path); - if (retval < 0) { - goto err_out; - } - retval =3D symlink(oldpath.data, path.data); - break; - } - if (retval < 0) { - retval =3D -errno; - } - -err_out: - resetugid(cur_uid, cur_gid); -unmarshal_err_out: - v9fs_string_free(&path); - v9fs_string_free(&oldpath); - return retval; -} - -/* - * create a file and send fd on success - * return -errno on error - */ -static int do_create(struct iovec *iovec) -{ - int ret; - V9fsString path; - int flags, mode, uid, gid, cur_uid, cur_gid; - - v9fs_string_init(&path); - ret =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "sdddd", - &path, &flags, &mode, &uid, &gid); - if (ret < 0) { - goto unmarshal_err_out; - } - ret =3D setugid(uid, gid, &cur_uid, &cur_gid); - if (ret < 0) { - goto unmarshal_err_out; - } - ret =3D open_regular(path.data, flags, mode); - if (ret < 0) { - ret =3D -errno; - } - - resetugid(cur_uid, cur_gid); -unmarshal_err_out: - v9fs_string_free(&path); - return ret; -} - -/* - * open a file and send fd on success - * return -errno on error - */ -static int do_open(struct iovec *iovec) -{ - int flags, ret; - V9fsString path; - - v9fs_string_init(&path); - ret =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &flags); - if (ret < 0) { - goto err_out; - } - ret =3D open_regular(path.data, flags, 0); - if (ret < 0) { - ret =3D -errno; - } -err_out: - v9fs_string_free(&path); - return ret; -} - -/* create unix domain socket and return the descriptor */ -static int proxy_socket(const char *path, uid_t uid, gid_t gid) -{ - int sock, client; - struct sockaddr_un proxy, qemu; - socklen_t size; - - /* requested socket already exists, refuse to start */ - if (!access(path, F_OK)) { - do_log(LOG_CRIT, "socket already exists\n"); - return -1; - } - - if (strlen(path) >=3D sizeof(proxy.sun_path)) { - do_log(LOG_CRIT, "UNIX domain socket path exceeds %zu characters\n= ", - sizeof(proxy.sun_path)); - return -1; - } - - sock =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) { - do_perror("socket"); - return -1; - } - - /* mask other part of mode bits */ - umask(7); - - proxy.sun_family =3D AF_UNIX; - strcpy(proxy.sun_path, path); - if (bind(sock, (struct sockaddr *)&proxy, - sizeof(struct sockaddr_un)) < 0) { - do_perror("bind"); - goto error; - } - if (chown(proxy.sun_path, uid, gid) < 0) { - do_perror("chown"); - goto error; - } - if (listen(sock, 1) < 0) { - do_perror("listen"); - goto error; - } - - size =3D sizeof(qemu); - client =3D accept(sock, (struct sockaddr *)&qemu, &size); - if (client < 0) { - do_perror("accept"); - goto error; - } - close(sock); - return client; - -error: - close(sock); - return -1; -} - -static void usage(void) -{ - fprintf(stderr, "usage: %s\n" - " -p|--path 9p path to export\n" - " {-f|--fd } socket file descriptor to be u= sed\n" - " {-s|--socket socket file used for communication= \n" - " \t-u|--uid -g|--gid } - uid:gid combination to gi= ve " - " access to this socket\n" - " \tNote: -s & -f can not be used together\n" - " [-n|--nodaemon] Run as a normal program\n", - prog_name); -} - -static int process_reply(int sock, int type, - struct iovec *out_iovec, int retval) -{ - switch (type) { - case T_OPEN: - case T_CREATE: - if (send_fd(sock, retval) < 0) { - return -1; - } - break; - case T_MKNOD: - case T_MKDIR: - case T_SYMLINK: - case T_LINK: - case T_CHMOD: - case T_CHOWN: - case T_TRUNCATE: - case T_UTIME: - case T_RENAME: - case T_REMOVE: - case T_LSETXATTR: - case T_LREMOVEXATTR: - if (send_status(sock, out_iovec, retval) < 0) { - return -1; - } - break; - case T_LSTAT: - case T_STATFS: - case T_READLINK: - case T_LGETXATTR: - case T_LLISTXATTR: - case T_GETVERSION: - if (send_response(sock, out_iovec, retval) < 0) { - return -1; - } - break; - default: - return -1; - break; - } - return 0; -} - -static int process_requests(int sock) -{ - int flags; - int size =3D 0; - int retval =3D 0; - uint64_t offset; - ProxyHeader header; - int mode, uid, gid; - V9fsString name, value; - struct timespec spec[2]; - V9fsString oldpath, path; - struct iovec in_iovec, out_iovec; - - in_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - in_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - out_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - out_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - - while (1) { - /* - * initialize the header type, so that we send - * response to proper request type. - */ - header.type =3D 0; - retval =3D read_request(sock, &in_iovec, &header); - if (retval < 0) { - goto err_out; - } - - switch (header.type) { - case T_OPEN: - retval =3D do_open(&in_iovec); - break; - case T_CREATE: - retval =3D do_create(&in_iovec); - break; - case T_MKNOD: - case T_MKDIR: - case T_SYMLINK: - retval =3D do_create_others(header.type, &in_iovec); - break; - case T_LINK: - v9fs_string_init(&path); - v9fs_string_init(&oldpath); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, - "ss", &oldpath, &path); - if (retval > 0) { - retval =3D link(oldpath.data, path.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&oldpath); - v9fs_string_free(&path); - break; - case T_LSTAT: - case T_STATFS: - retval =3D do_stat(header.type, &in_iovec, &out_iovec); - break; - case T_READLINK: - retval =3D do_readlink(&in_iovec, &out_iovec); - break; - case T_CHMOD: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, - "sd", &path, &mode); - if (retval > 0) { - retval =3D chmod(path.data, mode); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_CHOWN: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sdd", &pa= th, - &uid, &gid); - if (retval > 0) { - retval =3D lchown(path.data, uid, gid); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_TRUNCATE: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sq", - &path, &offset); - if (retval > 0) { - retval =3D truncate(path.data, offset); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_UTIME: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sqqqq", &= path, - &spec[0].tv_sec, &spec[0].tv_nsec, - &spec[1].tv_sec, &spec[1].tv_nsec); - if (retval > 0) { - retval =3D utimensat(AT_FDCWD, path.data, spec, - AT_SYMLINK_NOFOLLOW); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_RENAME: - v9fs_string_init(&path); - v9fs_string_init(&oldpath); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, - "ss", &oldpath, &path); - if (retval > 0) { - retval =3D rename(oldpath.data, path.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&oldpath); - v9fs_string_free(&path); - break; - case T_REMOVE: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "s", &path= ); - if (retval > 0) { - retval =3D remove(path.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_LGETXATTR: - case T_LLISTXATTR: - retval =3D do_getxattr(header.type, &in_iovec, &out_iovec); - break; - case T_LSETXATTR: - v9fs_string_init(&path); - v9fs_string_init(&name); - v9fs_string_init(&value); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &= path, - &name, &value, &size, &flags); - if (retval > 0) { - retval =3D lsetxattr(path.data, - name.data, value.data, size, flags); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - v9fs_string_free(&name); - v9fs_string_free(&value); - break; - case T_LREMOVEXATTR: - v9fs_string_init(&path); - v9fs_string_init(&name); - retval =3D proxy_unmarshal(&in_iovec, - PROXY_HDR_SZ, "ss", &path, &name); - if (retval > 0) { - retval =3D lremovexattr(path.data, name.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - v9fs_string_free(&name); - break; - case T_GETVERSION: - retval =3D do_getversion(&in_iovec, &out_iovec); - break; - default: - goto err_out; - break; - } - - if (process_reply(sock, header.type, &out_iovec, retval) < 0) { - goto err_out; - } - } -err_out: - g_free(in_iovec.iov_base); - g_free(out_iovec.iov_base); - return -1; -} - -int main(int argc, char **argv) -{ - int sock; - uid_t own_u; - gid_t own_g; - char *rpath =3D NULL; - char *sock_name =3D NULL; - struct stat stbuf; - int c, option_index; -#ifdef FS_IOC_GETVERSION - int retval; - struct statfs st_fs; -#endif - - fprintf(stderr, "NOTE: The 9p 'proxy' backend is deprecated (since " - "QEMU 8.1) and will be removed in a future version of " - "QEMU!\n"); - - prog_name =3D g_path_get_basename(argv[0]); - - is_daemon =3D true; - sock =3D -1; - own_u =3D own_g =3D -1; - while (1) { - option_index =3D 0; - c =3D getopt_long(argc, argv, "p:nh?f:s:u:g:", helper_opts, - &option_index); - if (c =3D=3D -1) { - break; - } - switch (c) { - case 'p': - rpath =3D g_strdup(optarg); - break; - case 'n': - is_daemon =3D false; - break; - case 'f': - sock =3D atoi(optarg); - break; - case 's': - sock_name =3D g_strdup(optarg); - break; - case 'u': - own_u =3D atoi(optarg); - break; - case 'g': - own_g =3D atoi(optarg); - break; - case '?': - case 'h': - default: - usage(); - exit(EXIT_FAILURE); - } - } - - /* Parameter validation */ - if ((sock_name =3D=3D NULL && sock =3D=3D -1) || rpath =3D=3D NULL) { - fprintf(stderr, "socket, socket descriptor or path not specified\n= "); - usage(); - return -1; - } - - if (sock_name && sock !=3D -1) { - fprintf(stderr, "both named socket and socket descriptor specified= \n"); - usage(); - exit(EXIT_FAILURE); - } - - if (sock_name && (own_u =3D=3D -1 || own_g =3D=3D -1)) { - fprintf(stderr, "owner uid:gid not specified, "); - fprintf(stderr, - "owner uid:gid specifies who can access the socket file\n"= ); - usage(); - exit(EXIT_FAILURE); - } - - if (lstat(rpath, &stbuf) < 0) { - fprintf(stderr, "invalid path \"%s\" specified, %s\n", - rpath, strerror(errno)); - exit(EXIT_FAILURE); - } - - if (!S_ISDIR(stbuf.st_mode)) { - fprintf(stderr, "specified path \"%s\" is not directory\n", rpath); - exit(EXIT_FAILURE); - } - - if (is_daemon) { - if (daemon(0, 0) < 0) { - fprintf(stderr, "daemon call failed\n"); - exit(EXIT_FAILURE); - } - openlog(PROGNAME, LOG_PID, LOG_DAEMON); - } - - do_log(LOG_INFO, "Started\n"); - if (sock_name) { - sock =3D proxy_socket(sock_name, own_u, own_g); - if (sock < 0) { - goto error; - } - } - - if (chroot(rpath) < 0) { - do_perror("chroot"); - goto error; - } - if (chdir("/") < 0) { - do_perror("chdir"); - goto error; - } - - get_version =3D false; -#ifdef FS_IOC_GETVERSION - /* check whether underlying FS support IOC_GETVERSION */ - retval =3D statfs("/", &st_fs); - if (!retval) { - switch (st_fs.f_type) { - case EXT2_SUPER_MAGIC: - case BTRFS_SUPER_MAGIC: - case REISERFS_SUPER_MAGIC: - case XFS_SUPER_MAGIC: - get_version =3D true; - break; - } - } -#endif - - umask(0); - if (init_capabilities() < 0) { - goto error; - } - - process_requests(sock); -error: - g_free(rpath); - g_free(sock_name); - do_log(LOG_INFO, "Done\n"); - closelog(); - return 0; -} diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c deleted file mode 100644 index 7aac49ad4ad..00000000000 --- a/hw/9pfs/9p-proxy.c +++ /dev/null @@ -1,1279 +0,0 @@ -/* - * 9p Proxy callback - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * M. Mohan Kumar - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -/* - * Not so fast! You might want to read the 9p developer docs first: - * https://wiki.qemu.org/Documentation/9p - */ - -/* - * NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be - * removed in a future version of QEMU! - */ - -#include "qemu/osdep.h" -#include -#include -#include "9p.h" -#include "qapi/error.h" -#include "qemu/cutils.h" -#include "qemu/error-report.h" -#include "qemu/option.h" -#include "fsdev/qemu-fsdev.h" -#include "9p-proxy.h" - -typedef struct V9fsProxy { - int sockfd; - QemuMutex mutex; - struct iovec in_iovec; - struct iovec out_iovec; -} V9fsProxy; - -/* - * Return received file descriptor on success in *status. - * errno is also returned on *status (which will be < 0) - * return < 0 on transport error. - */ -static int v9fs_receivefd(int sockfd, int *status) -{ - struct iovec iov; - struct msghdr msg; - struct cmsghdr *cmsg; - int retval, data, fd; - union MsgControl msg_control; - - iov.iov_base =3D &data; - iov.iov_len =3D sizeof(data); - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov =3D &iov; - msg.msg_iovlen =3D 1; - msg.msg_control =3D &msg_control; - msg.msg_controllen =3D sizeof(msg_control); - - do { - retval =3D recvmsg(sockfd, &msg, 0); - } while (retval < 0 && errno =3D=3D EINTR); - if (retval <=3D 0) { - return retval; - } - /* - * data is set to V9FS_FD_VALID, if ancillary data is sent. If this - * request doesn't need ancillary data (fd) or an error occurred, - * data is set to negative errno value. - */ - if (data !=3D V9FS_FD_VALID) { - *status =3D data; - return 0; - } - /* - * File descriptor (fd) is sent in the ancillary data. Check if we - * indeed received it. One of the reasons to fail to receive it is if - * we exceeded the maximum number of file descriptors! - */ - for (cmsg =3D CMSG_FIRSTHDR(&msg); cmsg; cmsg =3D CMSG_NXTHDR(&msg, cm= sg)) { - if (cmsg->cmsg_len !=3D CMSG_LEN(sizeof(int)) || - cmsg->cmsg_level !=3D SOL_SOCKET || - cmsg->cmsg_type !=3D SCM_RIGHTS) { - continue; - } - fd =3D *((int *)CMSG_DATA(cmsg)); - *status =3D fd; - return 0; - } - *status =3D -ENFILE; /* Ancillary data sent but not received */ - return 0; -} - -static ssize_t socket_read(int sockfd, void *buff, size_t size) -{ - ssize_t retval, total =3D 0; - - while (size) { - retval =3D read(sockfd, buff, size); - if (retval =3D=3D 0) { - return -EIO; - } - if (retval < 0) { - if (errno =3D=3D EINTR) { - continue; - } - return -errno; - } - size -=3D retval; - buff +=3D retval; - total +=3D retval; - } - return total; -} - -/* Converts proxy_statfs to VFS statfs structure */ -static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs) -{ - memset(stfs, 0, sizeof(*stfs)); - stfs->f_type =3D prstfs->f_type; - stfs->f_bsize =3D prstfs->f_bsize; - stfs->f_blocks =3D prstfs->f_blocks; - stfs->f_bfree =3D prstfs->f_bfree; - stfs->f_bavail =3D prstfs->f_bavail; - stfs->f_files =3D prstfs->f_files; - stfs->f_ffree =3D prstfs->f_ffree; -#ifdef CONFIG_DARWIN - /* f_namelen and f_frsize do not exist on Darwin */ - stfs->f_fsid.val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; - stfs->f_fsid.val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; -#else - stfs->f_fsid.__val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; - stfs->f_fsid.__val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; - stfs->f_namelen =3D prstfs->f_namelen; - stfs->f_frsize =3D prstfs->f_frsize; -#endif -} - -/* Converts proxy_stat structure to VFS stat structure */ -static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) -{ - memset(stbuf, 0, sizeof(*stbuf)); - stbuf->st_dev =3D prstat->st_dev; - stbuf->st_ino =3D prstat->st_ino; - stbuf->st_nlink =3D prstat->st_nlink; - stbuf->st_mode =3D prstat->st_mode; - stbuf->st_uid =3D prstat->st_uid; - stbuf->st_gid =3D prstat->st_gid; - stbuf->st_rdev =3D prstat->st_rdev; - stbuf->st_size =3D prstat->st_size; - stbuf->st_blksize =3D prstat->st_blksize; - stbuf->st_blocks =3D prstat->st_blocks; - stbuf->st_atime =3D prstat->st_atim_sec; - stbuf->st_mtime =3D prstat->st_mtim_sec; - stbuf->st_ctime =3D prstat->st_ctim_sec; -#ifdef CONFIG_DARWIN - stbuf->st_atimespec.tv_sec =3D prstat->st_atim_sec; - stbuf->st_mtimespec.tv_sec =3D prstat->st_mtim_sec; - stbuf->st_ctimespec.tv_sec =3D prstat->st_ctim_sec; - stbuf->st_atimespec.tv_nsec =3D prstat->st_atim_nsec; - stbuf->st_mtimespec.tv_nsec =3D prstat->st_mtim_nsec; - stbuf->st_ctimespec.tv_nsec =3D prstat->st_ctim_nsec; -#else - stbuf->st_atim.tv_sec =3D prstat->st_atim_sec; - stbuf->st_mtim.tv_sec =3D prstat->st_mtim_sec; - stbuf->st_ctim.tv_sec =3D prstat->st_ctim_sec; - stbuf->st_atim.tv_nsec =3D prstat->st_atim_nsec; - stbuf->st_mtim.tv_nsec =3D prstat->st_mtim_nsec; - stbuf->st_ctim.tv_nsec =3D prstat->st_ctim_nsec; -#endif -} - -/* - * Response contains two parts - * {header, data} - * header.type =3D=3D T_ERROR, data -> -errno - * header.type =3D=3D T_SUCCESS, data -> response - * size of errno/response is given by header.size - * returns < 0, on transport error. response is - * valid only if status >=3D 0. - */ -static int v9fs_receive_response(V9fsProxy *proxy, int type, - int *status, void *response) -{ - int retval; - ProxyHeader header; - struct iovec *reply =3D &proxy->in_iovec; - - *status =3D 0; - reply->iov_len =3D 0; - retval =3D socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); - if (retval < 0) { - return retval; - } - reply->iov_len =3D PROXY_HDR_SZ; - retval =3D proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); - assert(retval =3D=3D 4 * 2); - /* - * if response size > PROXY_MAX_IO_SZ, read the response but ignore it= and - * return -ENOBUFS - */ - if (header.size > PROXY_MAX_IO_SZ) { - int count; - while (header.size > 0) { - count =3D MIN(PROXY_MAX_IO_SZ, header.size); - count =3D socket_read(proxy->sockfd, reply->iov_base, count); - if (count < 0) { - return count; - } - header.size -=3D count; - } - *status =3D -ENOBUFS; - return 0; - } - - retval =3D socket_read(proxy->sockfd, - reply->iov_base + PROXY_HDR_SZ, header.size); - if (retval < 0) { - return retval; - } - reply->iov_len +=3D header.size; - /* there was an error during processing request */ - if (header.type =3D=3D T_ERROR) { - int ret; - ret =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); - assert(ret =3D=3D 4); - return 0; - } - - switch (type) { - case T_LSTAT: { - ProxyStat prstat; - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, - "qqqdddqqqqqqqqqq", &prstat.st_dev, - &prstat.st_ino, &prstat.st_nlink, - &prstat.st_mode, &prstat.st_uid, - &prstat.st_gid, &prstat.st_rdev, - &prstat.st_size, &prstat.st_blksize, - &prstat.st_blocks, - &prstat.st_atim_sec, &prstat.st_atim_nsec, - &prstat.st_mtim_sec, &prstat.st_mtim_nsec, - &prstat.st_ctim_sec, &prstat.st_ctim_nsec= ); - assert(retval =3D=3D 8 * 3 + 4 * 3 + 8 * 10); - prstat_to_stat(response, &prstat); - break; - } - case T_STATFS: { - ProxyStatFS prstfs; - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, - "qqqqqqqqqqq", &prstfs.f_type, - &prstfs.f_bsize, &prstfs.f_blocks, - &prstfs.f_bfree, &prstfs.f_bavail, - &prstfs.f_files, &prstfs.f_ffree, - &prstfs.f_fsid[0], &prstfs.f_fsid[1], - &prstfs.f_namelen, &prstfs.f_frsize); - assert(retval =3D=3D 8 * 11); - prstatfs_to_statfs(response, &prstfs); - break; - } - case T_READLINK: { - V9fsString target; - v9fs_string_init(&target); - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &target); - strcpy(response, target.data); - v9fs_string_free(&target); - break; - } - case T_LGETXATTR: - case T_LLISTXATTR: { - V9fsString xattr; - v9fs_string_init(&xattr); - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &xattr); - memcpy(response, xattr.data, xattr.size); - v9fs_string_free(&xattr); - break; - } - case T_GETVERSION: - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "q", response); - assert(retval =3D=3D 8); - break; - default: - return -1; - } - if (retval < 0) { - *status =3D retval; - } - return 0; -} - -/* - * return < 0 on transport error. - * *status is valid only if return >=3D 0 - */ -static int v9fs_receive_status(V9fsProxy *proxy, - struct iovec *reply, int *status) -{ - int retval; - ProxyHeader header; - - *status =3D 0; - reply->iov_len =3D 0; - retval =3D socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); - if (retval < 0) { - return retval; - } - reply->iov_len =3D PROXY_HDR_SZ; - retval =3D proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); - assert(retval =3D=3D 4 * 2); - retval =3D socket_read(proxy->sockfd, - reply->iov_base + PROXY_HDR_SZ, header.size); - if (retval < 0) { - return retval; - } - reply->iov_len +=3D header.size; - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); - assert(retval =3D=3D 4); - return 0; -} - -/* - * Proxy->header and proxy->request written to socket by QEMU process. - * This request read by proxy helper process - * returns 0 on success and -errno on error - */ -static int v9fs_request(V9fsProxy *proxy, int type, void *response, ...) -{ - dev_t rdev; - va_list ap; - int size =3D 0; - int retval =3D 0; - uint64_t offset; - ProxyHeader header =3D { 0, 0}; - struct timespec spec[2]; - int flags, mode, uid, gid; - V9fsString *name, *value; - V9fsString *path, *oldpath; - struct iovec *iovec =3D NULL, *reply =3D NULL; - - qemu_mutex_lock(&proxy->mutex); - - if (proxy->sockfd =3D=3D -1) { - retval =3D -EIO; - goto err_out; - } - iovec =3D &proxy->out_iovec; - reply =3D &proxy->in_iovec; - va_start(ap, response); - switch (type) { - case T_OPEN: - path =3D va_arg(ap, V9fsString *); - flags =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, flags); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_OPEN; - } - break; - case T_CREATE: - path =3D va_arg(ap, V9fsString *); - flags =3D va_arg(ap, int); - mode =3D va_arg(ap, int); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sdddd", path, - flags, mode, uid, gid); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_CREATE; - } - break; - case T_MKNOD: - path =3D va_arg(ap, V9fsString *); - mode =3D va_arg(ap, int); - rdev =3D va_arg(ap, long int); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ddsdq", - uid, gid, path, mode, rdev); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_MKNOD; - } - break; - case T_MKDIR: - path =3D va_arg(ap, V9fsString *); - mode =3D va_arg(ap, int); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ddsd", - uid, gid, path, mode); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_MKDIR; - } - break; - case T_SYMLINK: - oldpath =3D va_arg(ap, V9fsString *); - path =3D va_arg(ap, V9fsString *); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ddss", - uid, gid, oldpath, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_SYMLINK; - } - break; - case T_LINK: - oldpath =3D va_arg(ap, V9fsString *); - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ss", - oldpath, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LINK; - } - break; - case T_LSTAT: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LSTAT; - } - break; - case T_READLINK: - path =3D va_arg(ap, V9fsString *); - size =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, size); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_READLINK; - } - break; - case T_STATFS: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_STATFS; - } - break; - case T_CHMOD: - path =3D va_arg(ap, V9fsString *); - mode =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, mode); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_CHMOD; - } - break; - case T_CHOWN: - path =3D va_arg(ap, V9fsString *); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sdd", path, uid, gi= d); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_CHOWN; - } - break; - case T_TRUNCATE: - path =3D va_arg(ap, V9fsString *); - offset =3D va_arg(ap, uint64_t); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sq", path, offset); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_TRUNCATE; - } - break; - case T_UTIME: - path =3D va_arg(ap, V9fsString *); - spec[0].tv_sec =3D va_arg(ap, long); - spec[0].tv_nsec =3D va_arg(ap, long); - spec[1].tv_sec =3D va_arg(ap, long); - spec[1].tv_nsec =3D va_arg(ap, long); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sqqqq", path, - spec[0].tv_sec, spec[1].tv_nsec, - spec[1].tv_sec, spec[1].tv_nsec); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_UTIME; - } - break; - case T_RENAME: - oldpath =3D va_arg(ap, V9fsString *); - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ss", oldpath, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_RENAME; - } - break; - case T_REMOVE: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_REMOVE; - } - break; - case T_LGETXATTR: - size =3D va_arg(ap, int); - path =3D va_arg(ap, V9fsString *); - name =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, - "dss", size, path, name); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LGETXATTR; - } - break; - case T_LLISTXATTR: - size =3D va_arg(ap, int); - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ds", size, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LLISTXATTR; - } - break; - case T_LSETXATTR: - path =3D va_arg(ap, V9fsString *); - name =3D va_arg(ap, V9fsString *); - value =3D va_arg(ap, V9fsString *); - size =3D va_arg(ap, int); - flags =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sssdd", - path, name, value, size, flags); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LSETXATTR; - } - break; - case T_LREMOVEXATTR: - path =3D va_arg(ap, V9fsString *); - name =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ss", path, name); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LREMOVEXATTR; - } - break; - case T_GETVERSION: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_GETVERSION; - } - break; - default: - error_report("Invalid type %d", type); - retval =3D -EINVAL; - break; - } - va_end(ap); - - if (retval < 0) { - goto err_out; - } - - /* marshal the header details */ - retval =3D proxy_marshal(iovec, 0, "dd", header.type, header.size); - assert(retval =3D=3D 4 * 2); - header.size +=3D PROXY_HDR_SZ; - - retval =3D qemu_write_full(proxy->sockfd, iovec->iov_base, header.size= ); - if (retval !=3D header.size) { - goto close_error; - } - - switch (type) { - case T_OPEN: - case T_CREATE: - /* - * A file descriptor is returned as response for - * T_OPEN,T_CREATE on success - */ - if (v9fs_receivefd(proxy->sockfd, &retval) < 0) { - goto close_error; - } - break; - case T_MKNOD: - case T_MKDIR: - case T_SYMLINK: - case T_LINK: - case T_CHMOD: - case T_CHOWN: - case T_RENAME: - case T_TRUNCATE: - case T_UTIME: - case T_REMOVE: - case T_LSETXATTR: - case T_LREMOVEXATTR: - if (v9fs_receive_status(proxy, reply, &retval) < 0) { - goto close_error; - } - break; - case T_LSTAT: - case T_READLINK: - case T_STATFS: - case T_GETVERSION: - if (v9fs_receive_response(proxy, type, &retval, response) < 0) { - goto close_error; - } - break; - case T_LGETXATTR: - case T_LLISTXATTR: - if (!size) { - if (v9fs_receive_status(proxy, reply, &retval) < 0) { - goto close_error; - } - } else { - if (v9fs_receive_response(proxy, type, &retval, response) < 0)= { - goto close_error; - } - } - break; - } - -err_out: - qemu_mutex_unlock(&proxy->mutex); - return retval; - -close_error: - close(proxy->sockfd); - proxy->sockfd =3D -1; - qemu_mutex_unlock(&proxy->mutex); - return -EIO; -} - -static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *= stbuf) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_LSTAT, stbuf, fs_path); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return retval; -} - -static ssize_t proxy_readlink(FsContext *fs_ctx, V9fsPath *fs_path, - char *buf, size_t bufsz) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_READLINK, buf, fs_path, buf= sz); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return strlen(buf); -} - -static int proxy_close(FsContext *ctx, V9fsFidOpenState *fs) -{ - return close(fs->fd); -} - -static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs) -{ - return closedir(fs->dir.stream); -} - -static int proxy_open(FsContext *ctx, V9fsPath *fs_path, - int flags, V9fsFidOpenState *fs) -{ - fs->fd =3D v9fs_request(ctx->private, T_OPEN, NULL, fs_path, flags); - if (fs->fd < 0) { - errno =3D -fs->fd; - fs->fd =3D -1; - } - return fs->fd; -} - -static int proxy_opendir(FsContext *ctx, - V9fsPath *fs_path, V9fsFidOpenState *fs) -{ - int serrno, fd; - - fs->dir.stream =3D NULL; - fd =3D v9fs_request(ctx->private, T_OPEN, NULL, fs_path, O_DIRECTORY); - if (fd < 0) { - errno =3D -fd; - return -1; - } - fs->dir.stream =3D fdopendir(fd); - if (!fs->dir.stream) { - serrno =3D errno; - close(fd); - errno =3D serrno; - return -1; - } - return 0; -} - -static void proxy_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) -{ - rewinddir(fs->dir.stream); -} - -static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) -{ - return telldir(fs->dir.stream); -} - -static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) -{ - struct dirent *entry; - entry =3D readdir(fs->dir.stream); -#ifdef CONFIG_DARWIN - if (!entry) { - return NULL; - } - int td; - td =3D telldir(fs->dir.stream); - /* If telldir fails, fail the entire readdir call */ - if (td < 0) { - return NULL; - } - entry->d_seekoff =3D td; -#endif - return entry; -} - -static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) -{ - seekdir(fs->dir.stream, off); -} - -static ssize_t proxy_preadv(FsContext *ctx, V9fsFidOpenState *fs, - const struct iovec *iov, - int iovcnt, off_t offset) -{ - ssize_t ret; -#ifdef CONFIG_PREADV - ret =3D preadv(fs->fd, iov, iovcnt, offset); -#else - ret =3D lseek(fs->fd, offset, SEEK_SET); - if (ret >=3D 0) { - ret =3D readv(fs->fd, iov, iovcnt); - } -#endif - return ret; -} - -static ssize_t proxy_pwritev(FsContext *ctx, V9fsFidOpenState *fs, - const struct iovec *iov, - int iovcnt, off_t offset) -{ - ssize_t ret; - -#ifdef CONFIG_PREADV - ret =3D pwritev(fs->fd, iov, iovcnt, offset); -#else - ret =3D lseek(fs->fd, offset, SEEK_SET); - if (ret >=3D 0) { - ret =3D writev(fs->fd, iov, iovcnt); - } -#endif -#ifdef CONFIG_SYNC_FILE_RANGE - if (ret > 0 && ctx->export_flags & V9FS_IMMEDIATE_WRITEOUT) { - /* - * Initiate a writeback. This is not a data integrity sync. - * We want to ensure that we don't leave dirty pages in the cache - * after write when writeout=3Dimmediate is specified. - */ - sync_file_range(fs->fd, offset, ret, - SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRIT= E); - } -#endif - return ret; -} - -static int proxy_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_CHMOD, NULL, fs_path, - credp->fc_mode); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_mknod(FsContext *fs_ctx, V9fsPath *dir_path, - const char *name, FsCred *credp) -{ - int retval; - V9fsString fullname; - - v9fs_string_init(&fullname); - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - - retval =3D v9fs_request(fs_ctx->private, T_MKNOD, NULL, &fullname, - credp->fc_mode, credp->fc_rdev, - credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, - const char *name, FsCred *credp) -{ - int retval; - V9fsString fullname; - - v9fs_string_init(&fullname); - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - - retval =3D v9fs_request(fs_ctx->private, T_MKDIR, NULL, &fullname, - credp->fc_mode, credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_fstat(FsContext *fs_ctx, int fid_type, - V9fsFidOpenState *fs, struct stat *stbuf) -{ - int fd; - - if (fid_type =3D=3D P9_FID_DIR) { - fd =3D dirfd(fs->dir.stream); - } else { - fd =3D fs->fd; - } - return fstat(fd, stbuf); -} - -static int proxy_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *= name, - int flags, FsCred *credp, V9fsFidOpenState *fs) -{ - V9fsString fullname; - - v9fs_string_init(&fullname); - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - - fs->fd =3D v9fs_request(fs_ctx->private, T_CREATE, NULL, &fullname, fl= ags, - credp->fc_mode, credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - if (fs->fd < 0) { - errno =3D -fs->fd; - fs->fd =3D -1; - } - return fs->fd; -} - -static int proxy_symlink(FsContext *fs_ctx, const char *oldpath, - V9fsPath *dir_path, const char *name, FsCred *cre= dp) -{ - int retval; - V9fsString fullname, target; - - v9fs_string_init(&fullname); - v9fs_string_init(&target); - - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - v9fs_string_sprintf(&target, "%s", oldpath); - - retval =3D v9fs_request(fs_ctx->private, T_SYMLINK, NULL, &target, &fu= llname, - credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - v9fs_string_free(&target); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_link(FsContext *ctx, V9fsPath *oldpath, - V9fsPath *dirpath, const char *name) -{ - int retval; - V9fsString newpath; - - v9fs_string_init(&newpath); - v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name); - - retval =3D v9fs_request(ctx->private, T_LINK, NULL, oldpath, &newpath); - v9fs_string_free(&newpath); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) -{ - int retval; - - retval =3D v9fs_request(ctx->private, T_TRUNCATE, NULL, fs_path, size); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return 0; -} - -static int proxy_rename(FsContext *ctx, const char *oldpath, - const char *newpath) -{ - int retval; - V9fsString oldname, newname; - - v9fs_string_init(&oldname); - v9fs_string_init(&newname); - - v9fs_string_sprintf(&oldname, "%s", oldpath); - v9fs_string_sprintf(&newname, "%s", newpath); - retval =3D v9fs_request(ctx->private, T_RENAME, NULL, &oldname, &newna= me); - v9fs_string_free(&oldname); - v9fs_string_free(&newname); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_CHOWN, NULL, fs_path, - credp->fc_uid, credp->fc_gid); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_utimensat(FsContext *s, V9fsPath *fs_path, - const struct timespec *buf) -{ - int retval; - retval =3D v9fs_request(s->private, T_UTIME, NULL, fs_path, - buf[0].tv_sec, buf[0].tv_nsec, - buf[1].tv_sec, buf[1].tv_nsec); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_remove(FsContext *ctx, const char *path) -{ - int retval; - V9fsString name; - v9fs_string_init(&name); - v9fs_string_sprintf(&name, "%s", path); - retval =3D v9fs_request(ctx->private, T_REMOVE, NULL, &name); - v9fs_string_free(&name); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_fsync(FsContext *ctx, int fid_type, - V9fsFidOpenState *fs, int datasync) -{ - int fd; - - if (fid_type =3D=3D P9_FID_DIR) { - fd =3D dirfd(fs->dir.stream); - } else { - fd =3D fs->fd; - } - - if (datasync) { - return qemu_fdatasync(fd); - } else { - return fsync(fd); - } -} - -static int proxy_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *st= buf) -{ - int retval; - retval =3D v9fs_request(s->private, T_STATFS, stbuf, fs_path); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return retval; -} - -static ssize_t proxy_lgetxattr(FsContext *ctx, V9fsPath *fs_path, - const char *name, void *value, size_t size) -{ - int retval; - V9fsString xname; - - v9fs_string_init(&xname); - v9fs_string_sprintf(&xname, "%s", name); - retval =3D v9fs_request(ctx->private, T_LGETXATTR, value, size, fs_pat= h, - &xname); - v9fs_string_free(&xname); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static ssize_t proxy_llistxattr(FsContext *ctx, V9fsPath *fs_path, - void *value, size_t size) -{ - int retval; - retval =3D v9fs_request(ctx->private, T_LLISTXATTR, value, size, fs_pa= th); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *= name, - void *value, size_t size, int flags) -{ - int retval; - V9fsString xname, xvalue; - - v9fs_string_init(&xname); - v9fs_string_sprintf(&xname, "%s", name); - - v9fs_string_init(&xvalue); - xvalue.size =3D size; - xvalue.data =3D g_malloc(size); - memcpy(xvalue.data, value, size); - - retval =3D v9fs_request(ctx->private, T_LSETXATTR, value, fs_path, &xn= ame, - &xvalue, size, flags); - v9fs_string_free(&xname); - v9fs_string_free(&xvalue); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_lremovexattr(FsContext *ctx, V9fsPath *fs_path, - const char *name) -{ - int retval; - V9fsString xname; - - v9fs_string_init(&xname); - v9fs_string_sprintf(&xname, "%s", name); - retval =3D v9fs_request(ctx->private, T_LREMOVEXATTR, NULL, fs_path, &= xname); - v9fs_string_free(&xname); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_name_to_path(FsContext *ctx, V9fsPath *dir_path, - const char *name, V9fsPath *target) -{ - if (dir_path) { - v9fs_path_sprintf(target, "%s/%s", dir_path->data, name); - } else { - v9fs_path_sprintf(target, "%s", name); - } - return 0; -} - -static int proxy_renameat(FsContext *ctx, V9fsPath *olddir, - const char *old_name, V9fsPath *newdir, - const char *new_name) -{ - int ret; - V9fsString old_full_name, new_full_name; - - v9fs_string_init(&old_full_name); - v9fs_string_init(&new_full_name); - - v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name); - v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name); - - ret =3D proxy_rename(ctx, old_full_name.data, new_full_name.data); - v9fs_string_free(&old_full_name); - v9fs_string_free(&new_full_name); - return ret; -} - -static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir, - const char *name, int flags) -{ - int ret; - V9fsString fullname; - v9fs_string_init(&fullname); - - v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name); - ret =3D proxy_remove(ctx, fullname.data); - v9fs_string_free(&fullname); - - return ret; -} - -static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path, - mode_t st_mode, uint64_t *st_gen) -{ - int err; - - /* Do not try to open special files like device nodes, fifos etc - * we can get fd for regular files and directories only - */ - if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { - errno =3D ENOTTY; - return -1; - } - err =3D v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, path); - if (err < 0) { - errno =3D -err; - err =3D -1; - } - return err; -} - -static int connect_namedsocket(const char *path, Error **errp) -{ - int sockfd; - struct sockaddr_un helper; - - if (strlen(path) >=3D sizeof(helper.sun_path)) { - error_setg(errp, "socket name too long"); - return -1; - } - sockfd =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (sockfd < 0) { - error_setg_errno(errp, errno, "failed to create client socket"); - return -1; - } - strcpy(helper.sun_path, path); - helper.sun_family =3D AF_UNIX; - if (connect(sockfd, (struct sockaddr *)&helper, sizeof(helper)) < 0) { - error_setg_errno(errp, errno, "failed to connect to '%s'", path); - close(sockfd); - return -1; - } - - /* remove the socket for security reasons */ - unlink(path); - return sockfd; -} - -static void error_append_socket_sockfd_hint(Error *const *errp) -{ - error_append_hint(errp, "Either specify socket=3D/some/path where /som= e/path" - " points to a listening AF_UNIX socket or sock_fd=3D= fd" - " where fd is a file descriptor to a connected AF_UN= IX" - " socket\n"); -} - -static int proxy_parse_opts(QemuOpts *opts, FsDriverEntry *fs, Error **err= p) -{ - const char *socket =3D qemu_opt_get(opts, "socket"); - const char *sock_fd =3D qemu_opt_get(opts, "sock_fd"); - - if (!socket && !sock_fd) { - error_setg(errp, "both socket and sock_fd properties are missing"); - error_append_socket_sockfd_hint(errp); - return -1; - } - if (socket && sock_fd) { - error_setg(errp, "both socket and sock_fd properties are set"); - error_append_socket_sockfd_hint(errp); - return -1; - } - if (socket) { - fs->path =3D g_strdup(socket); - fs->export_flags |=3D V9FS_PROXY_SOCK_NAME; - } else { - fs->path =3D g_strdup(sock_fd); - fs->export_flags |=3D V9FS_PROXY_SOCK_FD; - } - return 0; -} - -static int proxy_init(FsContext *ctx, Error **errp) -{ - V9fsProxy *proxy =3D g_new(V9fsProxy, 1); - int sock_id; - - if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { - sock_id =3D connect_namedsocket(ctx->fs_root, errp); - } else { - sock_id =3D atoi(ctx->fs_root); - if (sock_id < 0) { - error_setg(errp, "socket descriptor not initialized"); - } - } - if (sock_id < 0) { - g_free(proxy); - return -1; - } - g_free(ctx->fs_root); - ctx->fs_root =3D NULL; - - proxy->in_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - proxy->in_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - proxy->out_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - proxy->out_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - - ctx->private =3D proxy; - proxy->sockfd =3D sock_id; - qemu_mutex_init(&proxy->mutex); - - ctx->export_flags |=3D V9FS_PATHNAME_FSCONTEXT; - ctx->exops.get_st_gen =3D proxy_ioc_getversion; - return 0; -} - -static void proxy_cleanup(FsContext *ctx) -{ - V9fsProxy *proxy =3D ctx->private; - - if (!proxy) { - return; - } - - g_free(proxy->out_iovec.iov_base); - g_free(proxy->in_iovec.iov_base); - if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { - close(proxy->sockfd); - } - g_free(proxy); -} - -FileOperations proxy_ops =3D { - .parse_opts =3D proxy_parse_opts, - .init =3D proxy_init, - .cleanup =3D proxy_cleanup, - .lstat =3D proxy_lstat, - .readlink =3D proxy_readlink, - .close =3D proxy_close, - .closedir =3D proxy_closedir, - .open =3D proxy_open, - .opendir =3D proxy_opendir, - .rewinddir =3D proxy_rewinddir, - .telldir =3D proxy_telldir, - .readdir =3D proxy_readdir, - .seekdir =3D proxy_seekdir, - .preadv =3D proxy_preadv, - .pwritev =3D proxy_pwritev, - .chmod =3D proxy_chmod, - .mknod =3D proxy_mknod, - .mkdir =3D proxy_mkdir, - .fstat =3D proxy_fstat, - .open2 =3D proxy_open2, - .symlink =3D proxy_symlink, - .link =3D proxy_link, - .truncate =3D proxy_truncate, - .rename =3D proxy_rename, - .chown =3D proxy_chown, - .utimensat =3D proxy_utimensat, - .remove =3D proxy_remove, - .fsync =3D proxy_fsync, - .statfs =3D proxy_statfs, - .lgetxattr =3D proxy_lgetxattr, - .llistxattr =3D proxy_llistxattr, - .lsetxattr =3D proxy_lsetxattr, - .lremovexattr =3D proxy_lremovexattr, - .name_to_path =3D proxy_name_to_path, - .renameat =3D proxy_renameat, - .unlinkat =3D proxy_unlinkat, -}; diff --git a/fsdev/meson.build b/fsdev/meson.build index e20d7255e1e..c751d8cb622 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -8,11 +8,3 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( if host_os in ['linux', 'darwin'] system_ss.add_all(fsdev_ss) endif - -if have_virtfs_proxy_helper - executable('virtfs-proxy-helper', - files('virtfs-proxy-helper.c', '9p-marshal.c', '9p-iov-marsha= l.c'), - dependencies: [qemuutil, libattr, libcap_ng], - install: true, - install_dir: get_option('libexecdir')) -endif diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index f1b62fa8c80..eceffdb81ea 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -2,7 +2,6 @@ fs_ss =3D ss.source_set() fs_ss.add(files( '9p-local.c', '9p-posix-acl.c', - '9p-proxy.c', '9p-synth.c', '9p-xattr-user.c', '9p-xattr.c', diff --git a/meson_options.txt b/meson_options.txt index 783b56bcb9b..5ee1d95c9ca 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -305,8 +305,6 @@ option('vhost_user_blk_server', type: 'feature', value:= 'auto', description: 'build vhost-user-blk server') option('virtfs', type: 'feature', value: 'auto', description: 'virtio-9p support') -option('virtfs_proxy_helper', type: 'feature', value: 'auto', - description: 'virtio-9p proxy helper support') option('libvduse', type: 'feature', value: 'auto', description: 'build VDUSE Library') option('vduse_blk_export', type: 'feature', value: 'auto', diff --git a/qemu-options.hx b/qemu-options.hx index d94e2cbbaeb..20a1ce0d43b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1766,29 +1766,18 @@ DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, " [[,throttling.bps-total-max=3Dbm]|[[,throttling.bps-read-max=3Drm][,= throttling.bps-write-max=3Dwm]]]\n" " [[,throttling.iops-total-max=3Dim]|[[,throttling.iops-read-max=3Dirm= ][,throttling.iops-write-max=3Diwm]]]\n" " [[,throttling.iops-size=3Dis]]\n" - "-fsdev proxy,id=3Did,socket=3Dsocket[,writeout=3Dimmediate][,readonly= =3Don]\n" - "-fsdev proxy,id=3Did,sock_fd=3Dsock_fd[,writeout=3Dimmediate][,readon= ly=3Don]\n" "-fsdev synth,id=3Did\n", QEMU_ARCH_ALL) =20 SRST ``-fsdev local,id=3Did,path=3Dpath,security_model=3Dsecurity_model [,write= out=3Dwriteout][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmode] [,throttlin= g.option=3Dvalue[,throttling.option=3Dvalue[,...]]]`` \=20 -``-fsdev proxy,id=3Did,socket=3Dsocket[,writeout=3Dwriteout][,readonly=3Do= n]`` - \ -``-fsdev proxy,id=3Did,sock_fd=3Dsock_fd[,writeout=3Dwriteout][,readonly= =3Don]`` - \ ``-fsdev synth,id=3Did[,readonly=3Don]`` Define a new file system device. Valid options are: =20 ``local`` Accesses to the filesystem are done by QEMU. =20 - ``proxy`` - Accesses to the filesystem are done by virtfs-proxy-helper(1). This - option is deprecated (since QEMU 8.1) and will be removed in a fut= ure - version of QEMU. Use ``local`` instead. - ``synth`` Synthetic filesystem, only used by QTests. =20 @@ -1813,8 +1802,6 @@ SRST security model is same as passthrough except the sever won't report failures if it fails to set file attributes like ownership. Security model is mandatory only for local fsdriver. - Other fsdrivers (like proxy) don't take security model as a - parameter. =20 ``writeout=3Dwriteout`` This is an optional argument. The only supported value is @@ -1827,16 +1814,6 @@ SRST Enables exporting 9p share as a readonly mount for guests. By default read-write access is given. =20 - ``socket=3Dsocket`` - Enables proxy filesystem driver to use passed socket file for - communicating with virtfs-proxy-helper(1). - - ``sock_fd=3Dsock_fd`` - Enables proxy filesystem driver to use passed socket descriptor - for communicating with virtfs-proxy-helper(1). Usually a helper - like libvirt will create socketpair and pass one of the fds as - sock\_fd. - ``fmode=3Dfmode`` Specifies the default mode for newly created files on the host. Works only with security models "mapped-xattr" and @@ -1889,18 +1866,12 @@ ERST DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, "-virtfs local,path=3Dpath,mount_tag=3Dtag,security_model=3Dmapped-xat= tr|mapped-file|passthrough|none\n" " [,id=3Did][,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfm= ode][,dmode=3Ddmode][,multidevs=3Dremap|forbid|warn]\n" - "-virtfs proxy,mount_tag=3Dtag,socket=3Dsocket[,id=3Did][,writeout=3Di= mmediate][,readonly=3Don]\n" - "-virtfs proxy,mount_tag=3Dtag,sock_fd=3Dsock_fd[,id=3Did][,writeout= =3Dimmediate][,readonly=3Don]\n" "-virtfs synth,mount_tag=3Dtag[,id=3Did][,readonly=3Don]\n", QEMU_ARCH_ALL) =20 SRST ``-virtfs local,path=3Dpath,mount_tag=3Dmount_tag ,security_model=3Dsecuri= ty_model[,writeout=3Dwriteout][,readonly=3Don] [,fmode=3Dfmode][,dmode=3Ddm= ode][,multidevs=3Dmultidevs]`` \=20 -``-virtfs proxy,socket=3Dsocket,mount_tag=3Dmount_tag [,writeout=3Dwriteou= t][,readonly=3Don]`` - \=20 -``-virtfs proxy,sock_fd=3Dsock_fd,mount_tag=3Dmount_tag [,writeout=3Dwrite= out][,readonly=3Don]`` - \ ``-virtfs synth,mount_tag=3Dmount_tag`` Define a new virtual filesystem device and expose it to the guest using a virtio-9p-device (a.k.a. 9pfs), which essentially means that a certa= in @@ -1917,11 +1888,6 @@ SRST ``local`` Accesses to the filesystem are done by QEMU. =20 - ``proxy`` - Accesses to the filesystem are done by virtfs-proxy-helper(1). - This option is deprecated (since QEMU 8.1) and will be removed in a - future version of QEMU. Use ``local`` instead. - ``synth`` Synthetic filesystem, only used by QTests. =20 @@ -1946,8 +1912,6 @@ SRST security model is same as passthrough except the sever won't report failures if it fails to set file attributes like ownership. Security model is mandatory only for local fsdriver. - Other fsdrivers (like proxy) don't take security model as a - parameter. =20 ``writeout=3Dwriteout`` This is an optional argument. The only supported value is @@ -1960,16 +1924,6 @@ SRST Enables exporting 9p share as a readonly mount for guests. By default read-write access is given. =20 - ``socket=3Dsocket`` - Enables proxy filesystem driver to use passed socket file for - communicating with virtfs-proxy-helper(1). Usually a helper like - libvirt will create socketpair and pass one of the fds as - sock\_fd. - - ``sock_fd`` - Enables proxy filesystem driver to use passed 'sock\_fd' as the - socket descriptor for interfacing with virtfs-proxy-helper(1). - ``fmode=3Dfmode`` Specifies the default mode for newly created files on the host. Works only with security models "mapped-xattr" and diff --git a/scripts/meson-buildoptions. b/scripts/meson-buildoptions. new file mode 100644 index 00000000000..e69de29bb2d diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 107a8f69ce5..3bee1c56df3 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -208,8 +208,6 @@ meson_options_help() { printf "%s\n" ' vhost-vdpa vhost-vdpa kernel backend support' printf "%s\n" ' virglrenderer virgl rendering support' printf "%s\n" ' virtfs virtio-9p support' - printf "%s\n" ' virtfs-proxy-helper' - printf "%s\n" ' virtio-9p proxy helper support' printf "%s\n" ' vmdk vmdk image format support' printf "%s\n" ' vmnet vmnet.framework network backend support' printf "%s\n" ' vnc VNC server' @@ -539,8 +537,6 @@ _meson_option_parse() { --disable-virglrenderer) printf "%s" -Dvirglrenderer=3Ddisabled ;; --enable-virtfs) printf "%s" -Dvirtfs=3Denabled ;; --disable-virtfs) printf "%s" -Dvirtfs=3Ddisabled ;; - --enable-virtfs-proxy-helper) printf "%s" -Dvirtfs_proxy_helper=3Denab= led ;; - --disable-virtfs-proxy-helper) printf "%s" -Dvirtfs_proxy_helper=3Ddis= abled ;; --enable-vmdk) printf "%s" -Dvmdk=3Denabled ;; --disable-vmdk) printf "%s" -Dvmdk=3Ddisabled ;; --enable-vmnet) printf "%s" -Dvmnet=3Denabled ;; --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059755; cv=none; d=zohomail.com; s=zohoarc; b=D7MZSsBP2mvzG8hYQRdcRifezaostvw1hZEWCM8RnFWioTFE9wUh0R2MVeeThTEahmUM1Wgd7u45z8L37PUR5HafSwbaD1xYPrqmQo1SVwnvn39ob36h+opZvIHjArxG1EFZm6WN9NTqBZJ6ssE6XPJOspAJya9Wv0uq8AuaCns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059755; 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=hGZU21yTeRuoz0XDxPyGfwViDrODDgVqraasQLedj+o=; b=RofI/7Zsy5IbmbxOyE65ggvDnBQYsnnHgt83KQuzDvDMNN5RFT7Vw9ns/LRXZkdIWxsGlWDg+Ys3KRNj3bZlClHRgkwTWgC/Kyp03zKGghNesm/YBzvo32qagxbJwFIzoSVnZacQkifLskwfo6dhK23/e+N798eH5R22sCbEz2c= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059755510561.2481630223974; Fri, 4 Oct 2024 09:35:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlHR-0000uZ-7M; Fri, 04 Oct 2024 12:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swlGu-0007mr-OV for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:17 -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 1swlGt-0006QY-22 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:16 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-YUrbTIb9PaeJMO8rSPGScA-1; Fri, 04 Oct 2024 12:35:13 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37cd4ec04a1so1076053f8f.0 for ; Fri, 04 Oct 2024 09:35:13 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86b1d5fesm19411035e9.24.2024.10.04.09.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059714; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hGZU21yTeRuoz0XDxPyGfwViDrODDgVqraasQLedj+o=; b=cafS5SpoMqTZVZwSlWSC4qyLDoY/BmQA0ph/69g9qy8ICyIcZwpPt1ar8RomyGq6TZYGVQ eQX7x3std3G2l67CNIJA5XIwAGyJxSe0BTgCM9Ds4ZcLxAdwOizAeCsYfwnJMAJgjM+MMU ElGf3Lsr4Rh/F3LNeawHLeiKFKf+y0s= X-MC-Unique: YUrbTIb9PaeJMO8rSPGScA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059711; x=1728664511; 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=hGZU21yTeRuoz0XDxPyGfwViDrODDgVqraasQLedj+o=; b=HyFK/DN68SDhjOpnZnZN2wx34e3fb6h5nsjogxZvG9XuaW2QkPBnoDWAmGQYaczt44 xo5Bc0KMeLEWpyqkb0CnnYQhMaXRXtiQb8VDSKX8BSmpLNR1IP1U+r16ELPqe6mpA20p ajcIw7+7aHcgI9bF4eqaxOCQlcNsaFW16zcyqvp+GQjA3drd1kg6xj94Rdsu0Ur1wHuL KfFoAHcK6BahcR1/VutSGbv4bsRv9v87MhitBInIRwN7qvz/m7cwqBG0Tlt4+n727+E+ jpfGP9kCDQB9lNgh8BByYqYYKum0DwaO+pbK+uNhDoiswGCaw1UthEbYIMESI4vZduvv es+Q== X-Gm-Message-State: AOJu0YzhfDdMekSwuf2YueBD+/hfJbqq3zuIGWloLeaSEu+88qO9Cqgt bpKpPGX3NM2xqyXy2HaX2lCBg2hVcslmeDbr/E+DOoWxlTzq3TqsxnkRivKz5l4ut1Tb4cA1KoG EAjrL6S8cFaQtoXuTp3Dr/qnXu20DcvPQFOG8MJapv9kSkCLA1eYRvjOKEmqUCmNPITN2GldO8s /2kAyJIsat+10l1RrEuByADf7u0W3XiZsVzHg3Lsg= X-Received: by 2002:a05:600c:5493:b0:426:6308:e2f0 with SMTP id 5b1f17b1804b1-42f85aee7d9mr24700715e9.26.1728059711110; Fri, 04 Oct 2024 09:35:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2OpTpzhrBnn+iKZ4dnehm97fDNEQ6RqYTguZ1dNxwuEyxKfJ4s1PtJxHkMcgbV41XiSGvsA== X-Received: by 2002:a05:600c:5493:b0:426:6308:e2f0 with SMTP id 5b1f17b1804b1-42f85aee7d9mr24700525e9.26.1728059710724; Fri, 04 Oct 2024 09:35:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 17/23] minikconf: print error entirely on stderr Date: Fri, 4 Oct 2024 18:34:09 +0200 Message-ID: <20241004163415.951106-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059757664116600 While debugging an invalid configuration, I noticed that the clauses debug ends up on stderr but the header ("The following clauses were found..." ends up on stdout. This makes the contents of meson-logs/meson-log.txt a bit confusing. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- scripts/minikconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/minikconf.py b/scripts/minikconf.py index bcd91015d34..6f7f43b2918 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -112,7 +112,7 @@ def has_value(self): def set_value(self, val, clause): self.clauses_for_var.append(clause) if self.has_value() and self.value !=3D val: - print("The following clauses were found for " + self.name) + print("The following clauses were found for " + self.name,= file=3Dsys.stderr) for i in self.clauses_for_var: print(" " + str(i), file=3Dsys.stderr) raise KconfigDataError('contradiction between clauses when= setting %s' % self) --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060210; cv=none; d=zohomail.com; s=zohoarc; b=WCUhvM3ad6YiSJ/Wh1GacRbFItWCnSQIoFxdxMF2Bs/Z0v1JWIATH8byBSXphdmLwmeRgbyRP/h89Iaq9CKOSMiseEtEUBdZeBITS6wT+xd5yLkSK3wmSTmhEX8Q3J/TaT67WdN6jLmaoU6HlavRIGHgcPTF6zzwYBG/wJ9WORo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060210; 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=MHCtYjHZqWBXvAFkbnga8RDrSxeZpUx1dCLsimTB34c=; b=nDKFCG1lfgTVdEZcFLENZW23XbgVCTF8HbRYOgXgEqhHA7iRcNobDwTK4nDP/yYndiVnquy06sKKtXmxpcqTcw8aOpe5Yd2GaKh51aS2DTJi6c9jRaVZ7oP2nTIpCEWPsePKBdHdh1UFZfkgxhlxsMGTFTfZGGmYTC0Q74Z0Dkg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060210286903.989812535309; Fri, 4 Oct 2024 09:43:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlI0-0001VE-9R; Fri, 04 Oct 2024 12:36:27 -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 1swlGy-00086k-1u for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:20 -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 1swlGw-0006Rc-AF for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:19 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-104-7bv196j8NrCXbkK40Ji2yw-1; Fri, 04 Oct 2024 12:35:16 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42f89a68c29so1416195e9.1 for ; Fri, 04 Oct 2024 09:35:16 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1691fff0sm35017f8f.51.2024.10.04.09.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059717; 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=MHCtYjHZqWBXvAFkbnga8RDrSxeZpUx1dCLsimTB34c=; b=WutKUpyHZnlK/GL9QgwYmX9gJLSp5+0Fsho0jUOiWAZx9fuM4DMpAM9qOVuL1IuVVftqme iWaxqsbE4hwOq9RpKkdjDBYX/HvGcG5NcqWhPEdDdA4CsI+LKgFqHoutZgygOAUDuzhoUT 2NUOjf3uU27FuVxvRuo2X8/U5shxUs8= X-MC-Unique: 7bv196j8NrCXbkK40Ji2yw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059714; x=1728664514; 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=MHCtYjHZqWBXvAFkbnga8RDrSxeZpUx1dCLsimTB34c=; b=AfWDdyQfE2w/pu/zmtovBsn+yKOsa4KZZfCelEyU4Buwcy6KM5l413Nti3ZP+bAvHG H0ChBt+QMUXmPGq2MQWyHaIi0DwgkZOXV1iWS+NkBPBo7udG7FGQoFEcQlRVOyBAWjVb CcpmXAeNYI6qLX7jSgUHXPV6D6hzrv0rp3NA1WNZSB1MsUvUBjmtMIaogxGNPEDlVUFC /E0RhmzobEVK21WoZng9pYMK5E9wYMTgLF4ORu2i803150zvdfpxEBE2xffCLT104wBs 809/lHHGul69/oTeWYz6OKaB5YYXTy0wC2vffXle9b7McVPiYud9kf+5ZfCMQDj/mvyk qNsQ== X-Gm-Message-State: AOJu0YxOW420yy9Tj6YKZQbSkMoEeHWd/TuM04IySSqv4f3DG2GZlEU+ U7R292sPH8vEozymgoWEMRGxoTi/jg0LT9CvvlnvRMNJXlmPoFKwjouBt6ictybGqIBYiOoqk+o eHw0ksRT0JZujZr+WK0Ycx3Nt9S4S/qOPVFFGas42U+7bbSaQOAK46pGZLXg7CC/g0l/oaObS3u YUHMk9B8jlAr37w+/yGPICQnfVNXUw+18hiMxMbgc= X-Received: by 2002:a5d:5306:0:b0:37c:c842:a16e with SMTP id ffacd0b85a97d-37d0e6f28a5mr2251527f8f.5.1728059714059; Fri, 04 Oct 2024 09:35:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/Hy6Sdyxc915rkTtKJcvJ5h+axZmR6OEQFFkAHW1qxMFwNhFqm3SYIrvsQ7K7MRn6WoRlOQ== X-Received: by 2002:a5d:5306:0:b0:37c:c842:a16e with SMTP id ffacd0b85a97d-37d0e6f28a5mr2251505f8f.5.1728059713547; Fri, 04 Oct 2024 09:35:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha Subject: [PULL 18/23] accel/kvm: refactor dirty ring setup Date: Fri, 4 Oct 2024 18:34:10 +0200 Message-ID: <20241004163415.951106-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060211999116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha Refactor setting up of dirty ring code in kvm_init() so that is can be reused in the future patchsets. Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240912061838.4501-1-anisinha@redhat.com Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 88 +++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e06cf3a4157..e57492fda5c 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2435,6 +2435,55 @@ static int find_kvm_machine_type(MachineState *ms) return type; } =20 +static int kvm_setup_dirty_ring(KVMState *s) +{ + uint64_t dirty_log_manual_caps; + int ret; + + /* + * Enable KVM dirty ring if supported, otherwise fall back to + * dirty logging mode + */ + ret =3D kvm_dirty_ring_init(s); + if (ret < 0) { + return ret; + } + + /* + * KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is not needed when dirty ring is + * enabled. More importantly, KVM_DIRTY_LOG_INITIALLY_SET will assume= no + * page is wr-protected initially, which is against how kvm dirty ring= is + * usage - kvm dirty ring requires all pages are wr-protected at the v= ery + * beginning. Enabling this feature for dirty ring causes data corrup= tion. + * + * TODO: Without KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 and kvm clear dirty= log, + * we may expect a higher stall time when starting the migration. In = the + * future we can enable KVM_CLEAR_DIRTY_LOG to work with dirty ring to= o: + * instead of clearing dirty bit, it can be a way to explicitly wr-pro= tect + * guest pages. + */ + if (!s->kvm_dirty_ring_size) { + dirty_log_manual_caps =3D + kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2); + dirty_log_manual_caps &=3D (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | + KVM_DIRTY_LOG_INITIALLY_SET); + s->manual_dirty_log_protect =3D dirty_log_manual_caps; + if (dirty_log_manual_caps) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2= , 0, + dirty_log_manual_caps); + if (ret) { + warn_report("Trying to enable capability %"PRIu64" of " + "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed.= " + "Falling back to the legacy mode. ", + dirty_log_manual_caps); + s->manual_dirty_log_protect =3D 0; + } + } + } + + return 0; +} + static int kvm_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); @@ -2454,7 +2503,6 @@ static int kvm_init(MachineState *ms) const KVMCapabilityInfo *missing_cap; int ret; int type; - uint64_t dirty_log_manual_caps; =20 qemu_mutex_init(&kml_slots_lock); =20 @@ -2566,47 +2614,11 @@ static int kvm_init(MachineState *ms) s->coalesced_pio =3D s->coalesced_mmio && kvm_check_extension(s, KVM_CAP_COALESCED_PIO); =20 - /* - * Enable KVM dirty ring if supported, otherwise fall back to - * dirty logging mode - */ - ret =3D kvm_dirty_ring_init(s); + ret =3D kvm_setup_dirty_ring(s); if (ret < 0) { goto err; } =20 - /* - * KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is not needed when dirty ring is - * enabled. More importantly, KVM_DIRTY_LOG_INITIALLY_SET will assume= no - * page is wr-protected initially, which is against how kvm dirty ring= is - * usage - kvm dirty ring requires all pages are wr-protected at the v= ery - * beginning. Enabling this feature for dirty ring causes data corrup= tion. - * - * TODO: Without KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 and kvm clear dirty= log, - * we may expect a higher stall time when starting the migration. In = the - * future we can enable KVM_CLEAR_DIRTY_LOG to work with dirty ring to= o: - * instead of clearing dirty bit, it can be a way to explicitly wr-pro= tect - * guest pages. - */ - if (!s->kvm_dirty_ring_size) { - dirty_log_manual_caps =3D - kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2); - dirty_log_manual_caps &=3D (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | - KVM_DIRTY_LOG_INITIALLY_SET); - s->manual_dirty_log_protect =3D dirty_log_manual_caps; - if (dirty_log_manual_caps) { - ret =3D kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2= , 0, - dirty_log_manual_caps); - if (ret) { - warn_report("Trying to enable capability %"PRIu64" of " - "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed.= " - "Falling back to the legacy mode. ", - dirty_log_manual_caps); - s->manual_dirty_log_protect =3D 0; - } - } - } - #ifdef KVM_CAP_VCPU_EVENTS s->vcpu_events =3D kvm_check_extension(s, KVM_CAP_VCPU_EVENTS); #endif --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060098; cv=none; d=zohomail.com; s=zohoarc; b=TKPF87JPjpbJBq1e4KJPaljznQXk+BL1a52Nt3OasF3ORSKlluXIaP2vWNeQkCiECYRV3+H5EJ6+fjAAGvtFOBK16qUbw+FAQ/Zp2xesb+FM6hJwzepGVuYQlxw+6HpD6BLIKZeEKdmbp+h7bbvf/f+biIEWVxWOtTV1Rm/PrKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060098; 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=Setl3AJEVs0vHNQj7xHFFLMsRz7zXPg367b8l0cBJ90=; b=P0zhqEV5CNF3ggMu1yJZDAJfQy4SvLKPEuJHCnYR82u4UGSq5XzCIy+v15xkdlFdAEC1vk/a0xgKmRd2vTXtobf4Ic1fQVKkkTMovqoWLHqzqkQv1NfcicZd7TawZ7EIJHE7ijOUuMR3habquGyCi6gDfgj6SuiPel6wtZBu+PI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060098026649.4050178599289; Fri, 4 Oct 2024 09:41:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlJ2-0003iU-RL; Fri, 04 Oct 2024 12:37:29 -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 1swlH2-0008Q6-6H for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:24 -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 1swlGy-0006St-W5 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:23 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-4vL_DBguPh-braosBtRBbA-1; Fri, 04 Oct 2024 12:35:19 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d002fb48fso1065906f8f.3 for ; Fri, 04 Oct 2024 09:35:19 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1691a56dsm37118f8f.41.2024.10.04.09.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059720; 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=Setl3AJEVs0vHNQj7xHFFLMsRz7zXPg367b8l0cBJ90=; b=KYf9zxYYjXy6B8rKwx/UP+elyqfawLD7xFKmOTP3lMEi6tvQWrcB6HyaFd4gPIJ9rTF5KE 5j6CkIZ9/3KwYJ0JiF503cWQn9Kz3PK8upKn58VGxu+x5lKSMajUjbLMTQOjaCGKYuW15n GdC9e4sMPcAxS4Nd2g3f89pbICS/JWA= X-MC-Unique: 4vL_DBguPh-braosBtRBbA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059717; x=1728664517; 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=Setl3AJEVs0vHNQj7xHFFLMsRz7zXPg367b8l0cBJ90=; b=f35s0x2GNKU6PDtpSb0LMzzSollIIaD0Uh1bseN51hRtm6nONYfj1yDEsGOUOkxJta mMMUz6RWbiq00LEgWbMgPV+Cy7UgvU2g7PCdoI2efsA8b+DnEuvxyUQmhcxaEv4R+I47 Roqv+UZ5gQiJySdPPbHCNiKEL1SB7Q1wKg00nX2wKop3/HVxyXOfQM5RFy66zjZWzaA2 O7Fpkwi795TgsTix9uMeHb2LfR5/+7ojQgQvJKA2ndGKhNga8eAZhFBbfg/k276FqnL0 r5vIa1Wxk5Sm4LLHz+hyochHO1h5q1ph6ei6BBuRn2cDcYOEhRuwOu2ggihbnMhf/X9x sLGg== X-Gm-Message-State: AOJu0YwgeZZorj+21TuB+Ns4NplSDRDUvvRjvB4fG1ieWncr2c8HsZw0 q0iPcTrsErAd86Xu1hoagxCWYonIPCsZc3IxKFZ/BEgU5v52pZK+uB1P9tCyhFTOeUdUnEqQM25 IpuMPaVMqdEp8SiJHxUyB4wHOQVw2PltkpIFJT0ybZnwYSGr/iIqRhknyA4p2eVKo+oQwsM+i7v j/xyg7q+U73WxuOELuSzEEX05km+blra1Zds/FYAM= X-Received: by 2002:a5d:61d2:0:b0:37c:c9b9:3732 with SMTP id ffacd0b85a97d-37d0e748d0bmr2071635f8f.21.1728059717589; Fri, 04 Oct 2024 09:35:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxPhRqM9+Ss3iSXEHgauXPy5dtYAUhUYxZwRTzfRL/212X9bkUoLbQ28Fw52eqX790RAYQfg== X-Received: by 2002:a5d:61d2:0:b0:37c:c9b9:3732 with SMTP id ffacd0b85a97d-37d0e748d0bmr2071617f8f.21.1728059717095; Fri, 04 Oct 2024 09:35:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Julia Suvorova , Peter Xu Subject: [PULL 19/23] kvm: Allow kvm_arch_get/put_registers to accept Error** Date: Fri, 4 Oct 2024 18:34:11 +0200 Message-ID: <20241004163415.951106-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060099638116600 Content-Type: text/plain; charset="utf-8" From: Julia Suvorova This is necessary to provide discernible error messages to the caller. Signed-off-by: Julia Suvorova Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20240927104743.218468-2-jusual@redhat.com Signed-off-by: Paolo Bonzini --- include/sysemu/kvm.h | 4 ++-- accel/kvm/kvm-all.c | 41 +++++++++++++++++++++++++++++--------- target/arm/kvm.c | 4 ++-- target/i386/kvm/kvm.c | 4 ++-- target/loongarch/kvm/kvm.c | 4 ++-- target/mips/kvm.c | 4 ++-- target/ppc/kvm.c | 4 ++-- target/riscv/kvm/kvm-cpu.c | 4 ++-- target/s390x/kvm/kvm.c | 4 ++-- 9 files changed, 48 insertions(+), 25 deletions(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 613d3f7581f..c3a60b28909 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -359,7 +359,7 @@ int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run = *run); =20 int kvm_arch_process_async_events(CPUState *cpu); =20 -int kvm_arch_get_registers(CPUState *cpu); +int kvm_arch_get_registers(CPUState *cpu, Error **errp); =20 /* state subset only touched by the VCPU itself during runtime */ #define KVM_PUT_RUNTIME_STATE 1 @@ -368,7 +368,7 @@ int kvm_arch_get_registers(CPUState *cpu); /* full state set, modified during initialization or on vmload */ #define KVM_PUT_FULL_STATE 3 =20 -int kvm_arch_put_registers(CPUState *cpu, int level); +int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp); =20 int kvm_arch_get_default_type(MachineState *ms); =20 diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e57492fda5c..905fb844e46 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2793,9 +2793,15 @@ void kvm_flush_coalesced_mmio_buffer(void) static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data ar= g) { if (!cpu->vcpu_dirty && !kvm_state->guest_state_protected) { - int ret =3D kvm_arch_get_registers(cpu); + Error *err =3D NULL; + int ret =3D kvm_arch_get_registers(cpu, &err); if (ret) { - error_report("Failed to get registers: %s", strerror(-ret)); + if (err) { + error_reportf_err(err, "Failed to synchronize CPU state: "= ); + } else { + error_report("Failed to get registers: %s", strerror(-ret)= ); + } + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); vm_stop(RUN_STATE_INTERNAL_ERROR); } @@ -2813,9 +2819,15 @@ void kvm_cpu_synchronize_state(CPUState *cpu) =20 static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_da= ta arg) { - int ret =3D kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE); + Error *err =3D NULL; + int ret =3D kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE, &err); if (ret) { - error_report("Failed to put registers after reset: %s", strerror(-= ret)); + if (err) { + error_reportf_err(err, "Restoring resisters after reset: "); + } else { + error_report("Failed to put registers after reset: %s", + strerror(-ret)); + } cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); vm_stop(RUN_STATE_INTERNAL_ERROR); } @@ -2830,9 +2842,15 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu) =20 static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_dat= a arg) { - int ret =3D kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE); + Error *err =3D NULL; + int ret =3D kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE, &err); if (ret) { - error_report("Failed to put registers after init: %s", strerror(-r= et)); + if (err) { + error_reportf_err(err, "Putting registers after init: "); + } else { + error_report("Failed to put registers after init: %s", + strerror(-ret)); + } exit(1); } =20 @@ -3022,10 +3040,15 @@ int kvm_cpu_exec(CPUState *cpu) MemTxAttrs attrs; =20 if (cpu->vcpu_dirty) { - ret =3D kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE); + Error *err =3D NULL; + ret =3D kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE, &er= r); if (ret) { - error_report("Failed to put registers after init: %s", - strerror(-ret)); + if (err) { + error_reportf_err(err, "Putting registers after init: = "); + } else { + error_report("Failed to put registers after init: %s", + strerror(-ret)); + } ret =3D -1; break; } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 849e2e21b30..f1f1b5b375a 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2042,7 +2042,7 @@ static int kvm_arch_put_sve(CPUState *cs) return 0; } =20 -int kvm_arch_put_registers(CPUState *cs, int level) +int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) { uint64_t val; uint32_t fpr; @@ -2226,7 +2226,7 @@ static int kvm_arch_get_sve(CPUState *cs) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { uint64_t val; unsigned int el; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7a1f2bda767..0b03fb0577f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5210,7 +5210,7 @@ static int kvm_get_nested_state(X86CPU *cpu) return ret; } =20 -int kvm_arch_put_registers(CPUState *cpu, int level) +int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp) { X86CPU *x86_cpu =3D X86_CPU(cpu); int ret; @@ -5298,7 +5298,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); int ret; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 4786cd5efa4..30ec16025d4 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -588,7 +588,7 @@ static int kvm_loongarch_put_cpucfg(CPUState *cs) return ret; } =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { int ret; =20 @@ -616,7 +616,7 @@ int kvm_arch_get_registers(CPUState *cs) return ret; } =20 -int kvm_arch_put_registers(CPUState *cs, int level) +int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) { int ret; =20 diff --git a/target/mips/kvm.c b/target/mips/kvm.c index a631ab544f5..a98798c6691 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -1172,7 +1172,7 @@ static int kvm_mips_get_cp0_registers(CPUState *cs) return ret; } =20 -int kvm_arch_put_registers(CPUState *cs, int level) +int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) { CPUMIPSState *env =3D cpu_env(cs); struct kvm_regs regs; @@ -1207,7 +1207,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) return ret; } =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { CPUMIPSState *env =3D cpu_env(cs); int ret =3D 0; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 907dba60d1b..3efc28f18b3 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -900,7 +900,7 @@ int kvmppc_put_books_sregs(PowerPCCPU *cpu) return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, &sregs); } =20 -int kvm_arch_put_registers(CPUState *cs, int level) +int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; @@ -1205,7 +1205,7 @@ static int kvmppc_get_books_sregs(PowerPCCPU *cpu) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index f6e3156b8d2..2bfb112be08 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1192,7 +1192,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilitie= s[] =3D { KVM_CAP_LAST_INFO }; =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { int ret =3D 0; =20 @@ -1237,7 +1237,7 @@ int kvm_riscv_sync_mpstate_to_kvm(RISCVCPU *cpu, int = state) return 0; } =20 -int kvm_arch_put_registers(CPUState *cs, int level) +int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) { int ret =3D 0; =20 diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 94181d9281f..8ffe0159d82 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -472,7 +472,7 @@ static int can_sync_regs(CPUState *cs, int regs) #define KVM_SYNC_REQUIRED_REGS (KVM_SYNC_GPRS | KVM_SYNC_ACRS | \ KVM_SYNC_CRS | KVM_SYNC_PREFIX) =20 -int kvm_arch_put_registers(CPUState *cs, int level) +int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) { CPUS390XState *env =3D cpu_env(cs); struct kvm_fpu fpu =3D {}; @@ -598,7 +598,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs) +int kvm_arch_get_registers(CPUState *cs, Error **errp) { CPUS390XState *env =3D cpu_env(cs); struct kvm_fpu fpu; --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059803; cv=none; d=zohomail.com; s=zohoarc; b=YUsM3ggmiJyu0PaO0Pnwal985OMuQr5OVlDkXC0B1gGlvCIxhD5ssJaURiMrOzcUUneEIY+Se83Ym0DcNLkvY+O50VY/jhBY+SPx8YBjWBO0DhoegjfHcS0RWJg5+H17FBtu9Ie60GmGwI9UW2PkmHTE++AOvK0Zv7z/+oAQOnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059803; 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=zRvC2mnVWmRmKdKLdnn9nYwUy+TnAkjqCft8CNX5ggI=; b=BP/tvhZ9Wal29wgYpXQlahW8wjfeedM84VBieCe4nKFRaL0fXoHJ5M7hE5oe3shX8Yby8vhFw+6e5fxpDM5aYq0dhF4NhdGPcggthMcE8y/OyDplN3uQG2V+9vawBWmuozuj1qIC+NT5U99gQyqSfxN72a/AZKFjq59ZNT81VmE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17280598030511005.7720491092737; Fri, 4 Oct 2024 09:36:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlHY-00012x-HV; Fri, 04 Oct 2024 12:35: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 1swlH4-0008V8-BV for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:27 -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 1swlH2-0006Tv-K3 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:26 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-GgKRimlUNx-hNyryCpXzsw-1; Fri, 04 Oct 2024 12:35:22 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37ccc21ceb1so1022037f8f.2 for ; Fri, 04 Oct 2024 09:35:22 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d16921aa4sm34583f8f.64.2024.10.04.09.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059724; 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=zRvC2mnVWmRmKdKLdnn9nYwUy+TnAkjqCft8CNX5ggI=; b=ArzJk3s77tNl0biz4NSbnAtfOSZ0nK3RNCL9kghG11aqZ1SX7MXq7/JQWqdW6IcPnv9NNM iWooYdGH2Zsu0n0B3zJqAaM1Us0LNYC4dxIJzmuHhX7Jy8/IoWpToc318hY23N5giCLomY U4vffPN8zgy7E3PBUyi71ra+H85FqQo= X-MC-Unique: GgKRimlUNx-hNyryCpXzsw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059721; x=1728664521; 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=zRvC2mnVWmRmKdKLdnn9nYwUy+TnAkjqCft8CNX5ggI=; b=uLVgImRrrpoInLl9NOe69lfDyuwhdjD0/Fz8MOEBWS+Jebb4Hbo3vxFk3YO+JKo7bj fgS1ToCPwfsy7hhkT9A2gfOGqpndGas5HTFHSPs23wUVeP+AGUsT+dcyWjehGjxP2pBK 7vc+lOWaUN0bywX8k25xqn0lgz1UBByV88wCnqFxvIyi/Df221wtVZ0BoB+UDdlSDcW9 He9eJsXC3mJ48EX6Wb5DUQAdi3KjZVL8IsAd0a6cF5cWjGIR+HMWFuK7TbNbycuqxqct qbZ0VR6SiCV9V1vubysdJHXT+I5P1AY49qw/fB11oDiIgWCwKv39gezt7jexPk+XNmj7 98dw== X-Gm-Message-State: AOJu0YzE8SwCPJ06UpUj6+2zj/Unp1e0XyeD5KHklv8QLOeiDSJdJiAL ChY/VPYZJHFyZW3wmu6LkhbxAoalaRGhUt2go5uvZL25/bg1KcOob6sI0FIIwTgco+I3YQuZord TabEReTkDtQSVlNIZaa4nRtTL0UzdYHGO9X7g0et3RwZFzBiwCa/8kMN08HdX4zrJdRiMp7j1l4 TgA4ywkgBc9ZNgF+mID//vglZwG9scl103ZOwtmCQ= X-Received: by 2002:adf:8b16:0:b0:374:c69b:5a16 with SMTP id ffacd0b85a97d-37d0e8de89dmr2082813f8f.50.1728059720672; Fri, 04 Oct 2024 09:35:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHttAAS7WFdCRd0lnPyIqwC72c4U8D+Wb8GtiGTtzGKuEPe2HB8WuxzXTGE8w7cDwkKYO/EKw== X-Received: by 2002:adf:8b16:0:b0:374:c69b:5a16 with SMTP id ffacd0b85a97d-37d0e8de89dmr2082792f8f.50.1728059720166; Fri, 04 Oct 2024 09:35:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Julia Suvorova , Peter Xu Subject: [PULL 20/23] target/i386/kvm: Report which action failed in kvm_arch_put/get_registers Date: Fri, 4 Oct 2024 18:34:12 +0200 Message-ID: <20241004163415.951106-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059803811116600 Content-Type: text/plain; charset="utf-8" From: Julia Suvorova To help debug and triage future failure reports (akin to [1,2]) that may occur during kvm_arch_put/get_registers, the error path of each action is accompanied by unique error message. [1] https://issues.redhat.com/browse/RHEL-7558 [2] https://issues.redhat.com/browse/RHEL-21761 Signed-off-by: Julia Suvorova Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20240927104743.218468-3-jusual@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 0b03fb0577f..e6f94900f3c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5225,6 +5225,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level, = Error **errp) if (level >=3D KVM_PUT_RESET_STATE) { ret =3D kvm_put_msr_feature_control(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set feature control MS= R"); return ret; } } @@ -5232,12 +5233,14 @@ int kvm_arch_put_registers(CPUState *cpu, int level= , Error **errp) /* must be before kvm_put_nested_state so that EFER.SVME is set */ ret =3D has_sregs2 ? kvm_put_sregs2(x86_cpu) : kvm_put_sregs(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set special registers"); return ret; } =20 if (level >=3D KVM_PUT_RESET_STATE) { ret =3D kvm_put_nested_state(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set nested state"); return ret; } } @@ -5255,6 +5258,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level, = Error **errp) if (xen_mode =3D=3D XEN_EMULATE && level =3D=3D KVM_PUT_FULL_STATE) { ret =3D kvm_put_xen_state(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set Xen state"); return ret; } } @@ -5262,37 +5266,45 @@ int kvm_arch_put_registers(CPUState *cpu, int level= , Error **errp) =20 ret =3D kvm_getput_regs(x86_cpu, 1); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set general purpose regist= ers"); return ret; } ret =3D kvm_put_xsave(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set XSAVE"); return ret; } ret =3D kvm_put_xcrs(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set XCRs"); return ret; } ret =3D kvm_put_msrs(x86_cpu, level); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set MSRs"); return ret; } ret =3D kvm_put_vcpu_events(x86_cpu, level); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set vCPU events"); return ret; } if (level >=3D KVM_PUT_RESET_STATE) { ret =3D kvm_put_mp_state(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set MP state"); return ret; } } =20 ret =3D kvm_put_tscdeadline_msr(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set TSC deadline MSR"); return ret; } ret =3D kvm_put_debugregs(x86_cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to set debug registers"); return ret; } return 0; @@ -5307,6 +5319,7 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp) =20 ret =3D kvm_get_vcpu_events(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get vCPU events"); goto out; } /* @@ -5315,44 +5328,54 @@ int kvm_arch_get_registers(CPUState *cs, Error **er= rp) */ ret =3D kvm_get_mp_state(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get MP state"); goto out; } ret =3D kvm_getput_regs(cpu, 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get general purpose regist= ers"); goto out; } ret =3D kvm_get_xsave(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get XSAVE"); goto out; } ret =3D kvm_get_xcrs(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get XCRs"); goto out; } ret =3D has_sregs2 ? kvm_get_sregs2(cpu) : kvm_get_sregs(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get special registers"); goto out; } ret =3D kvm_get_msrs(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get MSRs"); goto out; } ret =3D kvm_get_apic(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get APIC"); goto out; } ret =3D kvm_get_debugregs(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get debug registers"); goto out; } ret =3D kvm_get_nested_state(cpu); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get nested state"); goto out; } #ifdef CONFIG_XEN_EMU if (xen_mode =3D=3D XEN_EMULATE) { ret =3D kvm_get_xen_state(cs); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to get Xen state"); goto out; } } --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060070; cv=none; d=zohomail.com; s=zohoarc; b=cxx0gu0PsD7SEjnifxappaimC60sSufBeup9qVRABZz6Vhq5tHLBsGx2dsRsovmHRIOloD7DtIQOQHPPpRco3vh5a9qx3oRug63Z9Ma7KvB8rhOccY/BbvJ7bBokp865aivCWAfLDYraMtZFAw0l1cLRnjj7AraF3HAUEYF7qxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060070; 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=7uWdMuqfxCw5Np2FFSdp69OVDoJ5makDfahK/kSKpIQ=; b=OVtEC8MNass+tB00+4OvlGwtVOjTYXPozpnhOSIvb6XZ4qYgUl5FsKaHVS+teZj74NuMQCkTQjOOLD/QbAnjg0dDennh0EwXY7mogx0lpL3DjUtoD9XqQ23WNQOLvtFnGDOPqRc1NVQeGf61Onvebz0f+U8z6rp5O7jiovJ5c5Q= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060070856639.9356945791964; Fri, 4 Oct 2024 09:41:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlJF-0005T2-Le; Fri, 04 Oct 2024 12:37:41 -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 1swlH7-0000At-4D for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:30 -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 1swlH5-0006Ur-AW for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:28 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-jyCNDfw-P_O9bT8D3ARejA-1; Fri, 04 Oct 2024 12:35:25 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42ca8037d9aso14223555e9.3 for ; Fri, 04 Oct 2024 09:35:25 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89ed9d4bsm1459855e9.42.2024.10.04.09.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059726; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7uWdMuqfxCw5Np2FFSdp69OVDoJ5makDfahK/kSKpIQ=; b=fwJOjlZhSavzcgw1iJWC0R+VWjJJ6Bs9xO5omkRubaPM6hCZMj1QKdFfDX0DH3+lLLEQNi VJW8BfvW93kGpOPoFD8ohF6S7F6OBY3rC9qUtjUrz7wZmQGqQWfJPhYsCyWrmE7IhJMxGw 6J+6MDPW/F6Wqm6Y9RIlDbB3e4naysM= X-MC-Unique: jyCNDfw-P_O9bT8D3ARejA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059723; x=1728664523; 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=7uWdMuqfxCw5Np2FFSdp69OVDoJ5makDfahK/kSKpIQ=; b=qlOXXDncW6gO5g0EA2GY+RvIVeW4GdHQWHGKbxT3YLaAuO+VEKpJbu2ohX+PBMII3r Pg/nZkl8c/+9pPFLVjiLB51JFvkDmP8ERF1ZSBuiM80v562t47JTJgtiDpHo8V0Y5oGs DBQ2W7lwoKys7Z5UMDH7rH2f86t/JR1NuDLCmLfaTD0WmXGXLdqVAANFQA5c6JZka7Ct ol1zvfGOIEV+O78MIRk2RE2ohBAvehXc9yS7uDgEAUxVbVk3iXgbNdlyAuVe+PS6aR8M M+hkP/LQCTPkmuXinHKsG0FpFLbhZdZttx6rOjfd2xIDqgWlELbpjbGUJpSpHexAofh+ ULGw== X-Gm-Message-State: AOJu0YxnZFj0LVRkMKI7xjUEfFmrAvp+TVhc4jeTd1K7wWI/A6IOL/0o 19UoYfPQl2AkItyaxJXjcTD7niy/VzL2zW7pbciAKGscYQkgcclSUyLATcWP0rTv4bc1oLEsZQD RLLx2DkNPAEN16xyJp48wwQPl2ktcbjls/vLQ6OsX8r9suXfszUR5FbEiAfcUGgvJCq4CXffCed litKuAZj7ZEbh4ie1gmT+yyBoKq5AtY7tpgWDqres= X-Received: by 2002:a7b:cc89:0:b0:42c:bd5b:cb53 with SMTP id 5b1f17b1804b1-42f85aef0bamr21673885e9.23.1728059723484; Fri, 04 Oct 2024 09:35:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLzkEF37x5PLR6J1A5gexFqbXLzkwyiSj7Q1gt03RPmTcumKVNCk27V4o3cYgscuYDLOENeA== X-Received: by 2002:a7b:cc89:0:b0:42c:bd5b:cb53 with SMTP id 5b1f17b1804b1-42f85aef0bamr21673655e9.23.1728059723014; Fri, 04 Oct 2024 09:35:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 21/23] qom: rename object_resolve_path_type() "ambiguousp" Date: Fri, 4 Oct 2024 18:34:13 +0200 Message-ID: <20241004163415.951106-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060071314116600 From: Marc-Andr=C3=A9 Lureau Make it match the function declaration & documentation. Signed-off-by: Marc-Andr=C3=A9 Lureau Link: https://lore.kernel.org/r/20241002080806.2868406-2-marcandre.lureau@r= edhat.com Signed-off-by: Paolo Bonzini --- qom/object.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qom/object.c b/qom/object.c index 28c5b66eab5..0adbef29462 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2184,7 +2184,7 @@ static Object *object_resolve_partial_path(Object *pa= rent, } =20 Object *object_resolve_path_type(const char *path, const char *typename, - bool *ambiguousp) + bool *ambiguous) { Object *obj; char **parts; @@ -2193,11 +2193,11 @@ Object *object_resolve_path_type(const char *path, = const char *typename, assert(parts); =20 if (parts[0] =3D=3D NULL || strcmp(parts[0], "") !=3D 0) { - bool ambiguous =3D false; + bool ambig =3D false; obj =3D object_resolve_partial_path(object_get_root(), parts, - typename, &ambiguous); - if (ambiguousp) { - *ambiguousp =3D ambiguous; + typename, &ambig); + if (ambiguous) { + *ambiguous =3D ambig; } } else { obj =3D object_resolve_abs_path(object_get_root(), parts + 1, type= name); --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059973; cv=none; d=zohomail.com; s=zohoarc; b=I09T8QHR4lzCvRE/6vHWH8aLsiixer8E5tD5insehpVZb8h8n3O591SN/Yiy1XWLR1Bv2b58Vf0mh9/7rVNo0CQm2EZQpEhnxdgAKAr7Rh2yeyVj6EfIfL5JpsGGcxCoNEZN1Cg3gGtaLahugqAGy3Yl0fSxx2p7U7MPv9IILOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059973; 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=xpRZLu1LDAQ4lHu80CpSku7vlaQLxLoF4YRF8+/3PN0=; b=hhq7OMnDMrTpg+WH8GBsf0+hmCIQraXb/AdcmnzuZ5/pbuttnA2bFcsbGIKWRlF3J/SzBEQTIQ2JmEwsXgBzu0AWjtkmYvt7CLvjYZ7WgCMpRnZFnnLv05F/yvjD3DYnWF8BDJqakvMURYRmBNr976lnD+WauOw3Pmx9hrlEdKI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172805997374125.43700697486372; Fri, 4 Oct 2024 09:39:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlJE-0005Rw-Rr; Fri, 04 Oct 2024 12:37:41 -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 1swlHA-0000b6-5J for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:32 -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 1swlH8-0006Vm-Ha for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:31 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-9K51u9bUMf660_J3xpLaPA-1; Fri, 04 Oct 2024 12:35:28 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42cb6f3c476so17432845e9.0 for ; Fri, 04 Oct 2024 09:35:28 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f89e83363sm1633325e9.6.2024.10.04.09.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059729; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xpRZLu1LDAQ4lHu80CpSku7vlaQLxLoF4YRF8+/3PN0=; b=XiPSAYtuhtFx50PBVtAozB4ncIkm4gJ3/EpElGYbVH94cKtej7/BKhf1emsHKlnCodx1zA YOH88rluighllbtd62az6GLnizFp4eG98JKknHFuozduWdAw9VYkeAyHXe7B1Q6YTYiBSC 5pwSnrWMEHzxn53RKbPWX7H2wXYRbkY= X-MC-Unique: 9K51u9bUMf660_J3xpLaPA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059727; x=1728664527; 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=xpRZLu1LDAQ4lHu80CpSku7vlaQLxLoF4YRF8+/3PN0=; b=ancgBlHWpcha1sBgm8kDJPAfX4qa/Sj8XR2vfvYFhWMljVVO9exB9CB+/cpz5YtziH dIIzRd2uXoMxg9QbuXpfDM+n+hvoI1M3T0TFBV8SUZ+qx2xO2Pri7essEiJo9RIMv3k2 RJqC0N9WCYOLS9ir+rhWKKz4BuGvBF4IE58aog2AqPezPLIsSudYcVxoh4vNuE43XWFv wb3l+1RMbMhBY1f7WJ5Cqhg7eut9zUlKDANzuqgzt4llUcnNRyLJhz68Q3qguJpbz065 dTYqHA3C4mAFtMvGfVfiWbF7cGqIs0YO2wpkPshd5cc9G+eL2AA+I3l2ywtt1rYRDVV1 TZwQ== X-Gm-Message-State: AOJu0Yxn8lJKh690h0uCV1ajTs3Tjn+88CX2J3j72ej2ls7YCCHuGZ9U CpGW4hddkODTveySHh7/1+wYsz2UswvkjIRRKdk5ADD6DEuDammQWkq7s1DvvVcaQ0BcibhnJo6 EGQP6J2Z9sDV9zzo9o9l8qWon7dZc9d7xKwDH5exMHOBreu5TLKV4mCBh2nuSS4uBzsBW+AVvTn yIrUD/uZ9sAGe8PCpuw7W+Egr8FCqCcKUOZmsB1Ww= X-Received: by 2002:a05:600c:4f4b:b0:42c:bd27:4be4 with SMTP id 5b1f17b1804b1-42f85aa62e7mr26746795e9.8.1728059726597; Fri, 04 Oct 2024 09:35:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/0YrhisACE/5G2wPphIx2CVyjsEnTn8543n1EBu2AAxiG0Gn0cmRPWf1RCBhWcQpYxKxY6g== X-Received: by 2002:a05:600c:4f4b:b0:42c:bd27:4be4 with SMTP id 5b1f17b1804b1-42f85aa62e7mr26746575e9.8.1728059726071; Fri, 04 Oct 2024 09:35:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 22/23] qom: set *ambiguous on all paths Date: Fri, 4 Oct 2024 18:34:14 +0200 Message-ID: <20241004163415.951106-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728059974751116600 From: Marc-Andr=C3=A9 Lureau So the caller contract is simpler. Signed-off-by: Marc-Andr=C3=A9 Lureau Link: https://lore.kernel.org/r/20241002080806.2868406-3-marcandre.lureau@r= edhat.com Signed-off-by: Paolo Bonzini --- qom/object.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qom/object.c b/qom/object.c index 0adbef29462..222804dcfb5 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2201,6 +2201,9 @@ Object *object_resolve_path_type(const char *path, co= nst char *typename, } } else { obj =3D object_resolve_abs_path(object_get_root(), parts + 1, type= name); + if (ambiguous) { + *ambiguous =3D false; + } } =20 g_strfreev(parts); --=20 2.46.1 From nobody Sat Nov 23 23:54:04 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728060032; cv=none; d=zohomail.com; s=zohoarc; b=TtNuSNmUHVutwte24Xgn/xHw2MhrpNv2iQbteSOBo7LD7QKyc97E40DFwdzoECdc5y/JhYetBfNKhK3TsXEBG9X3QpBmfE0HSfcSomWSn+J+9weYmSeSKfup+xsbgKo2lEOuXIUBb2NFjNam597IAy2G/Fb1Sk073LOKYsmFyQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728060032; 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=fOYQxlb8dWb3hQAPR7qPAEAmjAvpcOZoKc0Lj5UkEYs=; b=ZbqqkHM+jyx87m5gTinJ7lXnVZL9a6nRaTwqMsDFvh6PBYJjU1QBi2JvCw+42HFjuhvGhj8B8E9xm5plDSCq2QUcN4OTxAeJLG1mNqF9GZnUSV9YxWZgdbhbOFKMOoWKtsYU27bTA/0g//YjQ7EwjhOpOhVcyqq/0muc0uSxlHY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728060032126370.10183193106616; Fri, 4 Oct 2024 09:40:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlJK-000673-T0; Fri, 04 Oct 2024 12:37:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swlHC-0000oq-OV for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:36 -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 1swlHA-0006Wa-RI for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:34 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-Hism51xiOWmITFYCq6oljg-1; Fri, 04 Oct 2024 12:35:31 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37cd1fb9497so1691082f8f.1 for ; Fri, 04 Oct 2024 09:35:31 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1688a486sm55812f8f.0.2024.10.04.09.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059732; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fOYQxlb8dWb3hQAPR7qPAEAmjAvpcOZoKc0Lj5UkEYs=; b=JtoQ4w44vROSQ2tPoBG/oUbpTYRGZORJxdmI2JVkYW04E4QZlRHauufdCBiap1TLg2LbcD 8o4IViGsFkrpZ2txjYDTBuhfMhTYJEeQnjo8V1IetjzLKOqRa5o53gfgTjSxMP26QbA019 +sJEVMAcYXbmHk1aCD4E8p3RmsliyEo= X-MC-Unique: Hism51xiOWmITFYCq6oljg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059729; x=1728664529; 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=fOYQxlb8dWb3hQAPR7qPAEAmjAvpcOZoKc0Lj5UkEYs=; b=Fq8Nzm9jmf/qm3Z6S2fIn4MvGp1GblDMwpDqZh8I1GMB5LwLJM53bYsOoNJO1EptmQ rL+JK88q0JDkfIRFbNsY7q/GPOXy64TMwTU/eDy79GULagjFssUDoEhFxtJA42PS88DK 6+gwa4TpW9InU/CaFlLrWgNgToy8YIKc1+bq7+XTKvi6yjWIpKhAY2TSkcBm0sVk/hXq xA2ELAnI0w4jppU3Y+hsHbKvWsYHgmEDG1d+2QYYYj3Z3RMfb+IoFZTCvVPyZC9OYcoG mcxYLY/fqudqBdxpMdUM4tSRWAe0EW04L3MCQDYibko43QT75dsPTHX5uABAnrSp2mrZ +P6A== X-Gm-Message-State: AOJu0YzTHfkxFU1ouMhA5m7DP5jKzMWRaz0rrg1L2oKhA3ZxxCHQ/vyd QDtgbG/31JSkn47plIppA8UbszZ5RnZZFhMg2Z3i027y3gBN5tXO8v/Syx9oySLTq8NzYmLcduS DTd2cVqsPd909THHbYGxnHFT8iXRpIY8NxbD0TZGbDPMaUB5sLawpNazd5XT5lB39JGlPHE4bbB PMx4WaXItiEd+RXAMm33BMQp6NcejPpIvbTUgzUNQ= X-Received: by 2002:a05:6000:4027:b0:37c:c4c0:4545 with SMTP id ffacd0b85a97d-37d0f6a273emr2756055f8f.10.1728059729276; Fri, 04 Oct 2024 09:35:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXclZtSxrABT4Js56F5JgVI3AVPXr7Hp3OvWFOa+a+Md33A9vrxn8IFmtd5Ezw0CXC8fLSzA== X-Received: by 2002:a05:6000:4027:b0:37c:c4c0:4545 with SMTP id ffacd0b85a97d-37d0f6a273emr2756027f8f.10.1728059728757; Fri, 04 Oct 2024 09:35:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 23/23] qom: update object_resolve_path*() documentation Date: Fri, 4 Oct 2024 18:34:15 +0200 Message-ID: <20241004163415.951106-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1728060033240116600 From: Marc-Andr=C3=A9 Lureau - update doc to reflect that @ambiguous is now set true or false on failure - specify that @ambiguous is nullable - use some gtk-doc annotations Signed-off-by: Marc-Andr=C3=A9 Lureau Link: https://lore.kernel.org/r/20241002080806.2868406-4-marcandre.lureau@r= edhat.com Signed-off-by: Paolo Bonzini --- include/qom/object.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 13d3a655ddf..2af9854675c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1569,8 +1569,8 @@ char *object_get_canonical_path(const Object *obj); /** * object_resolve_path: * @path: the path to resolve - * @ambiguous: returns true if the path resolution failed because of an - * ambiguous match + * @ambiguous: (out) (optional): location to store whether the lookup fail= ed + * because it was ambiguous, or %NULL. Set to %false on success. * * There are two types of supported paths--absolute paths and partial path= s. *=20 @@ -1587,7 +1587,7 @@ char *object_get_canonical_path(const Object *obj); * only one match is found. If more than one match is found, a flag is * returned to indicate that the match was ambiguous. * - * Returns: The matched object or NULL on path lookup failure. + * Returns: The matched object or %NULL on path lookup failure. */ Object *object_resolve_path(const char *path, bool *ambiguous); =20 @@ -1595,10 +1595,10 @@ Object *object_resolve_path(const char *path, bool = *ambiguous); * object_resolve_path_type: * @path: the path to resolve * @typename: the type to look for. - * @ambiguous: returns true if the path resolution failed because of an - * ambiguous match + * @ambiguous: (out) (optional): location to store whether the lookup fail= ed + * because it was ambiguous, or %NULL. Set to %false on success. * - * This is similar to object_resolve_path. However, when looking for a + * This is similar to object_resolve_path(). However, when looking for a * partial path only matches that implement the given type are considered. * This restricts the search and avoids spuriously flagging matches as * ambiguous. --=20 2.46.1