From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 6F669184E for ; Sat, 11 Jan 2025 00:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736556653; cv=none; b=ogHg1PPmH9YWvbO/3CvBZFMg/Ub8cUjtdrOLoWZFvxz5MMtTQMO0wPwBTQrf8GAuYyF68h7e2wfAhwhQ3MTny+zfu4cxWUFVIa5b5bV3DnHtlPvz2Sm333pn4Z49WW/exc/Ii+V0ZXFkAxDeaH8ZevHH7KAvAnaIKL8d0tK8ao4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736556653; c=relaxed/simple; bh=kul+Fw4DW6osdE/Z2GoPabxZf5HTWm/6V8saFNmXeC0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=H3gOaPL4koE8w+gty01TgEMyqeGVqk8sQ1hnIfvDH7gEYPw3IwofBEQ/UUvOsG5UN1EQqdcDK/PH1v44eNfGMOwE0ObZ6pyx61PV+sYbHAXq0Y2M0XQgqse/DyteTjssIh/mbL2pEJ6RrDg4fzV5fgBApkf3XC5rl4YCSInGqMM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zOeOfTcf; arc=none smtp.client-ip=209.85.216.74 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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zOeOfTcf" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2f2a9f056a8so4815061a91.2 for ; Fri, 10 Jan 2025 16:50:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736556652; x=1737161452; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=9xron+KThU7T77R5VL2QV4m0fAH5NzD4XXNwhcBHEXQ=; b=zOeOfTcfKH+ZQfrz7ABQmoiuYih5lDbKsFY6HCUkRlmttJF2Phaovqeo7pa+ulHEVo i3A+k7IEno1pKfxygSo4V2sFFZgnCBjCE469E+gFiXTHuJg8qi0jFDqQGgBfqV7EZ+ZY Pu47VyxcqvlnJ9AA6Q/b+4xCAK6N1/oM0lKAdmqvwO+L/aL/eFfwIwaF6JOmf04sU2lu 4ypCzMtzkGMeHs3ez0qrEsF7nD7EElApVRp1Q0HM8CafMW6wSPIC/Gy2aoWFQhAReD0x 9i50xMmssa/YkKp/20YT8kKCKHfXUy6Xif96j+O5CUzEQSOaFXrHifZzHsQlppI3vABY XWRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736556652; x=1737161452; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9xron+KThU7T77R5VL2QV4m0fAH5NzD4XXNwhcBHEXQ=; b=ohlQ81XWu4k8xKAi84my0swrDZZEB18Ub1hLEPHOYddPyOR2i5MajLGjMQVZjqg/lE h42MVGCG/+pmpUFtNHJy8T0W9LTZAXuD9gg7aHRu1Slno7F7VTQ6IxQlZnu9l7HSvSrP TZRk0hOs8uJiVKRzo2gyWOd8GE6V4SdLXpo2vKudO2CF689fNCC6CKOJfhvlqCH+wSqg 9b6I/f41uRn19Y2V+cTsUpbksTwIPAsmdTXM0w2FMUKl6EzCb3PaYH8/+8nnOIcoJ2LX OqL9gVn/uNK5o8VPouqH7OPlCQJWA/KQBz7+UqQtErfWSxJoboquPHMmXzemJdXJdZ9p F4Sw== X-Forwarded-Encrypted: i=1; AJvYcCVvhrjfPeqM4FjhnNl/1hCKGHVXDxRMNjX0X0ue3rtApomB4TekbPVBUt4GSqYm7A2tzh6oZiS3Oy/uQBo=@vger.kernel.org X-Gm-Message-State: AOJu0YzDuI91Vx3zoUGd51xTv/F2Rpo+9mq7iISz6RIpGE6CJpRFpS5s +XyDHu7N9tfz65quawbKsYiaeODrGAMDQmDnhnvtPRdaZ2EmwBmJ6Q5LAGEDchr5JbSCdWBZILV o8w== X-Google-Smtp-Source: AGHT+IFGHtmLK/IYHq0Rf1GMc11fdZBgGQoU3n0wFrQS04Q/FED/wp6nrTmZr2LCO3EYVe3us4g7I58uwQQ= X-Received: from pjbqi13.prod.google.com ([2002:a17:90b:274d:b0:2ef:82c0:cb8d]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a44:b0:2ea:61de:38f7 with SMTP id 98e67ed59e1d1-2f548f1d420mr19019162a91.29.1736556651751; Fri, 10 Jan 2025 16:50:51 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 10 Jan 2025 16:50:40 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250111005049.1247555-1-seanjc@google.com> Subject: [PATCH v2 0/9] KVM: selftests: Binary stats fixes and infra updates From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson , Paolo Bonzini Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Fix a handful of bugs in the binary stats infrastructure, expand support to vCPU-scoped stats, enumerate all KVM stats in selftests, and use the enumerated stats to assert at compile-time that {vm,vcpu}_get_stat() is getting a stat that actually exists. Most of the bugs are benign, and AFAICT, none actually cause problems in the current code base. The worst of the bugs is lack of validation that the requested stat actually exists, which is quite annoying if someone fat fingers a stat name, tries to get a vCPU stat on a VM FD, etc. As called out multiple times in v1, I'm on the fence regarding the last patch (compile-time assertions). My plan is to apply everything except the last patch fairly quickly, so that the vCPU stats stuff in particular can be used in x86 tests, and hold off on the compile-time assertion goo until someone comes along with a strong opinion one way or the other. v2: - Update rlimit number of files for all "standard" VMs. - Account for the vCPU stats fd when updating rlimits. v1: https://lore.kernel.org/all/20241220013906.3518334-1-seanjc@google.com Sean Christopherson (9): KVM: selftests: Fix mostly theoretical leak of VM's binary stats FD KVM: selftests: Close VM's binary stats FD when releasing VM KVM: selftests: Assert that __vm_get_stat() actually finds a stat KVM: selftests: Macrofy vm_get_stat() to auto-generate stat name string KVM: selftests: Add struct and helpers to wrap binary stats cache KVM: selftests: Get VM's binary stats FD when opening VM KVM: selftests: Adjust number of files rlimit for all "standard" VMs KVM: selftests: Add infrastructure for getting vCPU binary stats KVM: selftests: Add compile-time assertions to guard against stats typos .../kvm/include/arm64/kvm_util_arch.h | 12 ++ .../testing/selftests/kvm/include/kvm_util.h | 51 ++++++-- .../selftests/kvm/include/kvm_util_types.h | 6 + .../kvm/include/riscv/kvm_util_arch.h | 14 +++ .../kvm/include/s390/kvm_util_arch.h | 113 +++++++++++++++++ .../selftests/kvm/include/x86/kvm_util_arch.h | 52 ++++++++ .../selftests/kvm/kvm_create_max_vcpus.c | 28 +---- tools/testing/selftests/kvm/lib/kvm_util.c | 114 ++++++++++++------ .../kvm/x86/dirty_log_page_splitting_test.c | 6 +- .../selftests/kvm/x86/nx_huge_pages_test.c | 4 +- .../selftests/kvm/x86/xapic_ipi_test.c | 2 + 11 files changed, 324 insertions(+), 78 deletions(-) base-commit: 10b2c8a67c4b8ec15f9d07d177f63b563418e948 -- 2.47.1.613.gc27f4b7a9f-goog