From nobody Mon Feb 9 11:05:08 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAB2A24E4C3 for ; Sat, 18 Oct 2025 00:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760746082; cv=none; b=iakOqEQkmpABXV2GdmQzCXxvk2TgdOyET+6CNOeDSVJg7p2hSVb4iGWiI/K3MP1sYbHRvxlDcqLxCrg1d0XHsmSZ42dA29/7Y09M7MnhzE8/6Ej9GEL3WFPFQN8A8pG72xGfsYD5vBESEmDrBh8QFxeS4lb8cFVFlWZ4pCJM04o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760746082; c=relaxed/simple; bh=AadBcH6XuFUx3o/uyM4DKBt13sMey6ABFLv07q0/8bs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l92qTMBwNYiaLvLyzSTCwu9sBtF2UeTlgrUWvLdczkqqgDSV9ILJusJMmuZydjgYo73Vzp3T0pF9wQSzBbzSboYdj6UfKrqyQJgUzvGJjiwrRMz/WwNeygdzS8eLTkri5Ioah/tPK0kLClHCwT8XA0p4LmcNepmfV4bYqjYoQFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vipinsh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HmVv89H6; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vipinsh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HmVv89H6" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b632471eda1so2191191a12.0 for ; Fri, 17 Oct 2025 17:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760746080; x=1761350880; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Wf0V49FB2cemzthaMtFIU/EunA9kfJDBrs1ERauwF5c=; b=HmVv89H6ag/Qjal6jKnudJV076pe8pdNfdacsyF/qqidCkLPbYJLAOef/hhR85QBRb lOAbqn90v8jNs78lWIBwom7ceWAsdd41xE+TSnD4iq5+vsvUy3/J+3pM1STK4tMvl/tT X6ZF5ZiIgwUgTdI5q1GA9jWmWwhe8nBzyrqPU85q1YTQCeFU2/RGDfYS9/9uK0poSJio FCX0zwsW6B2ZoJu+IUitB0wLLMfrI1kzDzwW0Bhj9v/phQfrRzGCTOgbRNkQtt310g2D qKeO9yhNfKjoH69dNQ/6GZSZq46ICoXb7lZjb9qf2mVs1oSPHWVFJa01P00Tnjk+i2kt ca2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760746080; x=1761350880; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Wf0V49FB2cemzthaMtFIU/EunA9kfJDBrs1ERauwF5c=; b=hcqUt85iKwWdhhlRqVF/h5i0XEnfShquGcdajpSb5YQWov0VUVsPYYwXXkEibI1qT5 455xitXcvqVmxIFh2Fas/Eo6niaV6FNQhRrsi6uS2PPzliQGfHZ7kC78bKjBdhHhvYgp X01aGiEiKlftlwKIdFCdmxTM7kj+A8aKKw4iadkDcmZacJvhuoproAWOWIT71c7cQNcs dSfihUXDdOO7sOZnOjXCcvj6Xw1allrMpMrQ0CVqEIc833MrcwDq3Ndtu7vkP6b7mNRY QvCKG8XaFQK2SkNrj0OjKTBo27nwRAzuryKZ3CSLZLwTNicqpKsPRvf1sed+ez8e93o2 NbgQ== X-Forwarded-Encrypted: i=1; AJvYcCU6p7ToW7PPOJUsABGYPugBqHZ4koltBOUQJ9nS2vkosWuKu0alRhLwF5xzFxwHl0euNpPnSP0TqEBTlNM=@vger.kernel.org X-Gm-Message-State: AOJu0YzwWXB3bHzmN7P6BTgYgE9arB8gL7TqNI++gdeUMkGi69oyoVkJ aO4JERMyOQWjRZZGEVtGj//K/zSS/EONwBV5ccXqJtk05eDvE07vziO+V422XJCMy47f1L1BnVU /5xvCMtnvJg== X-Google-Smtp-Source: AGHT+IH3PSOfb25TFSyUmjh3MfKE86e6WefuP65fW8Nk0BjyxdVOlYJQBG/sYV/zeL2CFmcYNYIQrzD32GyP X-Received: from pjbfs17.prod.google.com ([2002:a17:90a:f291:b0:32e:bcc3:ea8e]) (user=vipinsh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:3c8e:b0:334:9c41:bdcb with SMTP id adf61e73a8af0-334a86445ddmr6954433637.58.1760746080171; Fri, 17 Oct 2025 17:08:00 -0700 (PDT) Date: Fri, 17 Oct 2025 17:07:13 -0700 In-Reply-To: <20251018000713.677779-1-vipinsh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251018000713.677779-1-vipinsh@google.com> X-Mailer: git-send-email 2.51.0.858.gf9c4a03a3a-goog Message-ID: <20251018000713.677779-22-vipinsh@google.com> Subject: [RFC PATCH 21/21] vfio: selftests: Validate vconfig preservation of VFIO PCI device during live update From: Vipin Sharma To: bhelgaas@google.com, alex.williamson@redhat.com, pasha.tatashin@soleen.com, dmatlack@google.com, jgg@ziepe.ca, graf@amazon.com Cc: pratyush@kernel.org, gregkh@linuxfoundation.org, chrisl@kernel.org, rppt@kernel.org, skhawaja@google.com, parav@nvidia.com, saeedm@nvidia.com, kevin.tian@intel.com, jrhilke@google.com, david@redhat.com, jgowans@amazon.com, dwmw2@infradead.org, epetron@amazon.de, junaids@google.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Vipin Sharma Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Test preservation of a VFIO PCI device virtual config (vconfig in struct vfio_pci_core_device{}) during the live update. Write some random data to PCI_INTERRUPT_LINE register which is virtualized by VFIO and verify that the same data is read after kexec. Certain bits in the config space are virtualized by VFIO, so write to them don't go to the device PCI config instead they are stored in memory. After live update, vconfig should have the value same as prior to kexec, which means vconfig should be saved in KHO and later retrieved to restore the device. Signed-off-by: Vipin Sharma --- .../testing/selftests/vfio/vfio_pci_liveupdate_test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/vfio/vfio_pci_liveupdate_test.c b/tool= s/testing/selftests/vfio/vfio_pci_liveupdate_test.c index 9fd0061348e0..2d80fdcb1ef7 100644 --- a/tools/testing/selftests/vfio/vfio_pci_liveupdate_test.c +++ b/tools/testing/selftests/vfio/vfio_pci_liveupdate_test.c @@ -15,12 +15,14 @@ =20 #define SESSION_NAME "multi_file_session" #define TOKEN 1234 +#define RANDOM_DATA 0x12 =20 static void run_pre_kexec(int luo_fd, const char *bdf) { struct vfio_pci_device *device; int session_fd; u16 command; + u8 data; =20 device =3D vfio_pci_device_init(bdf, "iommufd"); =20 @@ -30,6 +32,10 @@ static void run_pre_kexec(int luo_fd, const char *bdf) vfio_pci_config_writew(device, PCI_COMMAND, command | PCI_COMMAND_MASTER); =20 + vfio_pci_config_writeb(device, PCI_INTERRUPT_LINE, RANDOM_DATA); + data =3D vfio_pci_config_readb(device, PCI_INTERRUPT_LINE); + VFIO_ASSERT_EQ(data, RANDOM_DATA); + session_fd =3D luo_create_session(luo_fd, SESSION_NAME); VFIO_ASSERT_GE(session_fd, 0, "Failed to create session %s", SESSION_NAME); @@ -51,6 +57,7 @@ static void run_post_kexec(int luo_fd, const char *bdf) int vfio_fd; struct vfio_pci_device *device; u16 command; + u8 data; =20 =20 session_fd =3D luo_retrieve_session(luo_fd, SESSION_NAME); @@ -74,6 +81,9 @@ static void run_post_kexec(int luo_fd, const char *bdf) =20 command =3D vfio_pci_config_readw(device, PCI_COMMAND); VFIO_ASSERT_TRUE(command & PCI_COMMAND_MASTER); + + data =3D vfio_pci_config_readb(device, PCI_INTERRUPT_LINE); + VFIO_ASSERT_EQ(data, RANDOM_DATA); vfio_pci_device_cleanup(device); } =20 --=20 2.51.0.858.gf9c4a03a3a-goog