From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 98553299923 for ; Thu, 9 Jul 2026 20:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783628467; cv=none; b=lBqqesF0GTImPwVX+4RkFX1q6W37ol0RUCk9zpZz5Lf21t31Tr+Bk2AoQWL6eAWXZIaqOVxcT/NqNJH8Enqlqqbkj+mzmdYBU2ILeTyG6x1a7buPX9+gi+D9Q8Vkb/ikdL8uug0wuwqNeJLUsV1EStxPM3Po+EaO8f09M+9hrB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783628467; c=relaxed/simple; bh=q2ZOUSVusqbM4msiHCHWzW5ZDBfus1hiVGMu5NriqoI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OJ0XcIey5iQTdGa0fM8iW7GrKTWp6QA4KNQ3Q8mXpNUZYhxkSt+uXr4C66J5dC7582ViJKBK3/rF/lsP3VUDU+67CjJlaKhy3InJhoQdGDiSJjgNmvxCgJXlrgAeelWvxJaPHzJsk8vhOMhjHxVQ7xjpPGPUa9HUtpDc5ITnUoU= 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=ZR/QVdia; arc=none smtp.client-ip=209.85.210.201 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="ZR/QVdia" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-845bc2e658aso172432b3a.3 for ; Thu, 09 Jul 2026 13:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783628466; x=1784233266; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CxKcxzuNFCTiWIY9TtzP+QfZ+srbbSC9teFUzdNxgfk=; b=ZR/QVdiaOBlQ0i+ETgfWfoIPL3QBVl3FoOx2sBoETol7+XeRTwzd/e6seEznhNESGM 24VT7q4r0tkJ9hNAJ1Hu3UIBMA3PAFEbkCiwZQt18O6mJtvYXNPPuwH51B6UHVPT7qJh e2IPIWM2Q6T+WjFZclCUZg5tFXhtLhxRBSvyompWayqZO0UuRJFdrg8mPxreIESg464a r1rODfxjceJAvL8qgwtmiMdvDzG3zPffF5MfnN8nQeXsy4TpssOemz71/E24Ugp0rbGT BXsoQ9XCTN7pd7X2k+KqxUFBNP8wTRw7Ki/cmHSJbsGzDpStk2QOH+BmHEiu3dix9K0R BpcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783628466; x=1784233266; h=content-type: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:content-type; bh=CxKcxzuNFCTiWIY9TtzP+QfZ+srbbSC9teFUzdNxgfk=; b=N6a28Bk/16rgNzU2jOL7uBqHodzMrMkGK7hkMscxz7xfZ9PQTCTuvnCywN6v+Ey3Cf m6egxYfvajh4yMnXJYMDy70DvLinMwIY2k6cskakax18COI02Oqx9riOWGXENdHC1wBS 0NTYX3P5Q3t93xy2SPqmQAaWeMI1yt0L6vD4jrieVH8mWsoP3ifovEuli8NbL8in2ChW FpFnYhl+3oroeQLI7trLtHSjERoP+IfV/CIpYVkKTslkuQVnA71jRDAk5GtikZShtazJ 7s4bt0nxUUe+Rm5NfHa0qwSBiNIrnFgweWl2oN9cOIA6LbxU1S/8nyUr6PI+e4Eamnt0 J86g== X-Forwarded-Encrypted: i=1; AHgh+RowADfrtOumH3+MBlDcRMMBqeaTp9+W8bHigmzAGqeZBg2AC7xCqSI5nmd9rjXpWzx0L1uAR0d8mo7gWF0=@vger.kernel.org X-Gm-Message-State: AOJu0YyFyRcVCdeeDqhPFiwtph4X1gk7mfxjwT+4GkG+Yf6sgeB2uP4V T7PTdK4xhdG7LA2gMbTx8xOHLWlsgrJ3LPXvcli+QxJnafCvzr4PdvayQ+InU2yDOsslf9/rMs+ vQtM8TA== X-Received: from pfbmc20.prod.google.com ([2002:a05:6a00:7694:b0:846:3c78:e2e8]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:aa09:b0:845:62ce:d5ae with SMTP id d2e1a72fcca58-84843021d3amr8051184b3a.18.1783628465756; Thu, 09 Jul 2026 13:21:05 -0700 (PDT) Date: Thu, 9 Jul 2026 13:21:05 -0700 In-Reply-To: <20260709174955.628913-2-hemanth.selam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260709164751.621326-1-hemanth.selam@gmail.com> <20260709174955.628913-1-hemanth.selam@gmail.com> <20260709174955.628913-2-hemanth.selam@gmail.com> Message-ID: Subject: Re: [PATCH v2 1/2] KVM: selftests: SEV: Verify unsupported VM types are rejected at creation From: Sean Christopherson To: Hemanth Selam Cc: pbonzini@redhat.com, shuah@kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Jul 09, 2026, Hemanth Selam wrote: > @@ -73,19 +74,34 @@ static void test_init2_invalid(unsigned long vm_type, struct kvm_sev_init *init, > kvm_vm_free(vm); > } > > +static void test_create_invalid_type(unsigned long vm_type, const char *msg) > +{ > + int fd = __kvm_ioctl(kvm_fd, KVM_CREATE_VM, (void *)vm_type); > + int err = errno; > + > + /* Clean up before asserting; TEST_ASSERT() aborts on failure. */ Literally every test relies on the kernel to clean up fds on an early exit. I see no reason for this to behave differently. Also, Sashiko was wrong. If KVM_CREATE_VM fails with something other than EINVAL, the assert will NOT fire, but fd will be < 0. > + if (fd >= 0) > + close(fd); > + > + TEST_ASSERT(fd < 0 && err == EINVAL, > + "KVM_CREATE_VM should reject unsupported type (%s), got fd=%d errno=%d", > + msg, fd, err); test_assert logs the errno, no need to spit it out here as well. > +} > + > void test_vm_types(void) > { > test_init2(KVM_X86_SEV_VM, &(struct kvm_sev_init){}); > > - /* > - * TODO: check that unsupported types cannot be created. Probably > - * a separate selftest. Heh, I agree with the comment: put this in a separate selftest. This doesn't have anything to do with KVM_SEV_INIT2, and in fact doesn't even have anyting to do with SEV+ or even x86. E.g. add a kvm_vm_types_test that attempts to create all possible VM types, and asserts success/failure based on the output from kvm_check_cap(KVM_CAP_VM_TYPES).