From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 7BC493B0AC4 for ; Fri, 7 Aug 2026 07:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786086634; cv=none; b=fNW6Y+X1UGFk/CYHfS2M+18Lay3+4JvoRMOzyirCYYW0LYqUFxC9zl42iL/+c6bRQvMidlfKh6I7JopL0NCAdsuGD4wNzjCWGwXWMGvhHHus0VJk9+gQnUU/G/XMQA7/cshGYKv1IVG7MTkbwmvJFsTKpIF6RRSZoucs4uwWmMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786086634; c=relaxed/simple; bh=IAgQobVEQ0CWQcCIqZTlDhgLxtmPcEiR8bt94FC10is=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QFOvJIh2McO7eOWjU5hpXxWRYiUsVdb2xqiXa7cAiC1vKmmqpXqGprr9zyViEWG/VsRz18xXt26RUtzs6273/Hx80G1U2047uLTBXlqDF9FZPJa9sDU98VGgHP6UecpZ53B7bm79Im2H8RDdY0Wb6niOIiOjBJXa9ochjS+zi+k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EzhEskIj; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EzhEskIj" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-ca12086c06eso2593032a12.0 for ; Fri, 07 Aug 2026 00:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786086633; x=1786691433; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=NPzl1sllQPeAew0/T4KJhPua2DmqJee68WA88kC38zk=; b=EzhEskIjWl8fva57CgIzoxFvd043lv3Nl6E9MviHXT/y79n6BInwiff04k1j4zkgHj Rj7PMg0M0GNhh0Pz4oeOH5VUmvb+mhNh4L6wwK7V1AKunK3HCGDknIQ934/8y60n9q3i udFQn2kQFgsCFpki9VJ8ESMfeXx2vXd8YGfe9GWpnSd+qCSQ6qlI39VxG1R38Q9oIF+A qhxDGddeX36t8j9baVfEghGCRQcVFYzKyV3kByZ30hbSqsMtBjxU7YY0EAtgThMqc3RC 5tB61bchZyxOEoCiBzzFC7epBYOC2VTNaa/M3dKU4walYC5sWEKuEMcCQPXS8a+geYTX 2YDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786086633; x=1786691433; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NPzl1sllQPeAew0/T4KJhPua2DmqJee68WA88kC38zk=; b=X6KE2uJz5lyK43snD/L8DOcqqnGvCfaZECnp13ar0R359ETjCN6UQaZL2Q4QzVp0LE rQ2jxSqazTW7kVPFVK+vrXY2W/kIpRhcVbUIwwiQmOWOTXbbRmQNNUjDxZM3P8U8G2ez RBngDw2BzDXnHcxzjv9pYwvTzH1uHrkDKWIcj/IzTqR9iKzR9irsUYc2aasj3X3DIdP5 p+cfyNBYG84jMde5Vc9SprNiASvHdl/9JDfsKHfrlun9w5F8FKy/CESaKp15wua5FGML Yjss5optJnF0nqax+/cIv+lrqUriDsqbTMCWVyVu4aa2I31Fwo6EUke/sSHSulQ/KmMJ oOjg== X-Forwarded-Encrypted: i=1; AHgh+RqyaWB5T6ZmTByjSTgdtiUSH0JvkXOslMlNmG0GQs5lgRj0slOE9eBhH6E+sjook6vOqzbxwdJatcjQTIQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywot0BnEYA7RdgCWy6/bEdy1qPNdTNTN71FdLu9y8CwU6TskflR vLJJvpzd5Mqyj+5XXas+DbGQNUd6ErkweCPw93g+ky25NGrRiDa3YPaD X-Gm-Gg: AR+sD12tpaz0YcbMJxgipSf0zUAQM9h+Yj4UX7Ex+Ywx9g6WQST8bzOFGa6lm28R9nE rFQe7lgv9ypAPxYIHPxVDr6OUMAjWyn5n7Q04cjteffv7p5j+63gtQ2ApfYyOdMtLb0tL27wddC 33Lo93qB93vDUR5dqy9EovS81G0cedkV75UGJO5ZNSokvE/MNucjRcmy6ZNGPvvmSccZuiCaMfc B9aFeVxzjFs9o22jm+cTrsi5tLABF1oo4Px2wLKj/VWfr1dnADCeXZGoMGT3cj8RJUpSMJLYVuY oCsmMwf3YNJ8gDA0p3O40znBxaGPF+lESoRzQvIhPiCSxcktQhTEqZVvYkzrHoEKDoqXyfG0Lnw zMWbJW2GCgLnbMSzTSCGImM2DfRLtzhE4flKPNdxLgCxio7KGSYD1jw1GqH6IdajxSSyu3+16hX yUD945YXzvzwfGS2reNvjUqs31WWnthPutkXqOJoRmU/leWoLBASu7Knq5fQlPLiRiOGouQtbXj 2qsDjplZGF1 X-Received: by 2002:a05:6a20:7f9a:b0:3c3:875d:c538 with SMTP id adf61e73a8af0-3cb85dbce51mr23474608637.8.1786086632688; Fri, 07 Aug 2026 00:10:32 -0700 (PDT) Received: from 10-86-27-207.ban-spse ([165.204.217.251]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be8a706fsm4079878eec.8.2026.08.07.00.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 00:10:32 -0700 (PDT) From: Gokul K To: Sean Christopherson , Paolo Bonzini Cc: Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: selftests: Compare the entire XSAVE buffer in the SEV smoke test Date: Fri, 7 Aug 2026 12:40:26 +0530 Message-ID: <20260807071026.195503-1-gokul02k@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit compare_xsave() stops at index 4094, so the last byte of the XSAVE state is never compared. Both buffers handed to it are 4096 bytes: the host copy is a struct kvm_xsave, whose region[] member is 1024 u32s, and the guest copy is the PAGE_SIZE shared page that guest_code_xsave() runs XSAVE into. A VMSA synchronization bug that corrupted only that final byte would go unreported and the test would still pass. Bound the loop with sizeof(struct kvm_xsave) rather than an open-coded length, and make the index unsigned so it does not mix signedness with sizeof. Fixes: 8c53183dbaa2 ("selftests: kvm: add test for transferring FPU state into VMSA") Signed-off-by: Gokul K --- tools/testing/selftests/kvm/x86/sev_smoke_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c index 6b2cbe2a90b7..c7af27954356 100644 --- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c +++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c @@ -90,9 +90,10 @@ asm("guest_code_xsave:\n" static void compare_xsave(u8 *from_host, u8 *from_guest) { - int i; + unsigned int i; bool bad = false; - for (i = 0; i < 4095; i++) { + + for (i = 0; i < sizeof(struct kvm_xsave); i++) { if (from_host[i] != from_guest[i]) { printf("mismatch at %u | %02hhx %02hhx\n", i, from_host[i], from_guest[i]); -- 2.54.0