From nobody Sat Nov 23 22:38:27 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=1728637243; cv=none; d=zohomail.com; s=zohoarc; b=HLXqrL1NBqORCJpCOj2sRAU/V28qYn4klzj5CiRpXxiZ6o6RroDHJkiBni/4UjFYggAegjAcH8M4nqDtvYSCvM6nkUGQmB393Ftc4zY/DZi+D2e+aJdjZpQ2Z20YipQkujExaX4GF0mo7QnZBvS7xPhX6Od6mQALTaPHZJuadsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728637243; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XeVedSaUox6qACtW8EJ28JkUgbK5wJIqAzjoh6ebcek=; b=m8ZgspJFz13UIfAAqUk1xCfLoTLVNbi5f9vMak210Qim7bG1YAqTF3aMqFsNZEQxSSaNZRJ9+ihj4juDHt7XcotQx/yOIPxOeitMXK2ESjpjM0Sg1rtAZGKhB92BT3nFQkGvYc+6Z6Vvu3BZ7Vr7Piyz8Jzj5ZMdrWO+tmzbswM= 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 1728637243603202.9583423586588; Fri, 11 Oct 2024 02:00:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szBVD-0007lo-Rt; Fri, 11 Oct 2024 05:00:03 -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 1szBV5-0007kd-Fc for qemu-devel@nongnu.org; Fri, 11 Oct 2024 04:59:59 -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 1szBV2-0008Jf-6Z for qemu-devel@nongnu.org; Fri, 11 Oct 2024 04:59:54 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-8zpnXa8_MueLSkfNV8uPZg-1; Fri, 11 Oct 2024 04:59:49 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c93479b1dcso1287580a12.0 for ; Fri, 11 Oct 2024 01:59:49 -0700 (PDT) Received: from avogadro.local ([151.81.124.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7f266e8sm189152466b.63.2024.10.11.01.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 01:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728637191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XeVedSaUox6qACtW8EJ28JkUgbK5wJIqAzjoh6ebcek=; b=NhfJwcLXuPpsyD6Gvg3GlHnqK7mg4DX4w6ChYVUiwLgml90GSjBMqMT6B21z6nfZhgkwUi pSQ7AAojFmyWQT8VHWSnTgFFZCUYaM3TrPgBSKOy8rZBXVaLD8OlNvGuNFFJOwdicx0HeR WFxjHBQc5GiYEBYiVc4lcyqfsv4uCPo= X-MC-Unique: 8zpnXa8_MueLSkfNV8uPZg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728637188; x=1729241988; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XeVedSaUox6qACtW8EJ28JkUgbK5wJIqAzjoh6ebcek=; b=tezHKNhgwC1EoAfkxii6xmXGOabIAM36W9Vhiv/n0EU8X7XM0daaixnTVixMceJXZO /t0T3uoRg5q1nn3uej8EncjUavZsXoe49X70CuVmD0NbsJgZUDyisy7A8U7PX48Pu0S4 bk1kpDfh5CBFA2ko/GJT0vx0BelqaTslCuDhJYuc15XmndWQ1JZe8W1L7HIH7FX0iLOq z6b70MQAGLEpLpHetBym7EltVIALdvCPwKM8KJUH6YvQOgopHbOz06ya9brIEsOYlQT+ kNTRqKKQR2vbCj6e62apqrVOuRRDC25bXfqXt5QINoNYRnyax7IkiJd1T+wLueGpXtKt fFHg== X-Gm-Message-State: AOJu0YyyoK4kQpwd/6lx6vRy+tJFSCFVnRmqN1H7oakJHLZPAExpHp3a VRyrwcSg6s/l0bgtQTFJUV6bpCccQYS3mb/mj2HvwVQozJeXB+gHKOsrrAz3R3yXLy8hthr7VZA pKjpgqYgCpE517PYh+7mkyqdlRAAfcf6FIOJSIJVzQ0wkmHj9isM3ur22K3vRAF5RXSh+WkgWxP 7xC8EyBl/IR8vqV1jgwBqHa6IU11mVoyUW3JBB1vw= X-Received: by 2002:a17:906:c14c:b0:a99:435c:89f2 with SMTP id a640c23a62f3a-a99b95f5f72mr184633366b.63.1728637187733; Fri, 11 Oct 2024 01:59:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAu9vxzWaI+gDIbQ1AVvPP+ep+9xwQ0ezCRMHhUbnRmXfATiRm2D4hNC1Jkjdj0/iPsVvQSA== X-Received: by 2002:a17:906:c14c:b0:a99:435c:89f2 with SMTP id a640c23a62f3a-a99b95f5f72mr184631466b.63.1728637187303; Fri, 11 Oct 2024 01:59:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: erbse.13@gmx.de Subject: [PATCH] accel/kvm: check for KVM_CAP_MEMORY_ATTRIBUTES on vm Date: Fri, 11 Oct 2024 10:59:44 +0200 Message-ID: <20241011085944.25815-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 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.149, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728637244778116600 Content-Type: text/plain; charset="utf-8" The exact set of available memory attributes can vary by VM. In the future it might vary depending on enabled capabilities, too. Query the extension on the VM level instead of on the KVM level, and only after architecture-specific initialization. Inspired by an analogous patch by Tom Dohrmann. Signed-off-by: Paolo Bonzini Reviewed-by: Pankaj Gupta --- accel/kvm/kvm-all.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4287e254df8..482c5b24cf6 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2604,12 +2604,6 @@ static int kvm_init(MachineState *ms) goto err; } =20 - kvm_supported_memory_attributes =3D kvm_check_extension(s, KVM_CAP_MEM= ORY_ATTRIBUTES); - kvm_guest_memfd_supported =3D - kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) && - kvm_check_extension(s, KVM_CAP_USER_MEMORY2) && - (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE); - kvm_immediate_exit =3D kvm_check_extension(s, KVM_CAP_IMMEDIATE_EXIT); s->nr_slots_max =3D kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS); =20 @@ -2723,6 +2717,12 @@ static int kvm_init(MachineState *ms) goto err; } =20 + kvm_supported_memory_attributes =3D kvm_vm_check_extension(s, KVM_CAP_= MEMORY_ATTRIBUTES); + kvm_guest_memfd_supported =3D + kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) && + kvm_check_extension(s, KVM_CAP_USER_MEMORY2) && + (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE); + if (s->kernel_irqchip_split =3D=3D ON_OFF_AUTO_AUTO) { s->kernel_irqchip_split =3D mc->default_kernel_irqchip_split ? ON_= OFF_AUTO_ON : ON_OFF_AUTO_OFF; } --=20 2.46.2