Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1230477rdb; Wed, 24 Jan 2024 08:32:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCwMXqompVU164ycfa1I5Teh00I2mg47rf2T2CZWwHJ5e3y/+wltDNk8QfTluqKGboZ1J5 X-Received: by 2002:a17:906:9c85:b0:a31:1add:cc35 with SMTP id fj5-20020a1709069c8500b00a311addcc35mr1094410ejc.135.1706113955966; Wed, 24 Jan 2024 08:32:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706113955; cv=pass; d=google.com; s=arc-20160816; b=Sk4x6/wXTWDvJeVJoR47pLNrjTW9VIOeVrfqz/a/RvKV0+psGC4cTn+RdZWuf8fH2j +Z0MAO6WKFI6nFfgoVyfwM083F6V7nQaY/lHS6YlklFlwkTe3cSlcif/kvw0TWUwAxc+ pCMWVuhIBnw8aYViJEOY6d8LibqJhrnTOcg01LNjUacfI8QxwkBVmCGk3Mc50EhI07As N+qnn7ZzmM0JZzCbMwwttmz8A85wsnvv3wEBTZ/SgCmqfawWXzQvMd11sUgiUcWEmqhI bmmkrPZ2jx/7X2gCRgt2s/2r2eMXnz6ZNubrol786WpvCwYtNz/FQZGVDm8Q879hWSvr 9APA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=g82foanF1CJTmaDLSQP4Ghn9FVcWHiz28lTGASp7l48=; fh=gHuR4GM5tksW8ivRhHnPYoQcD2msXTnINDlTHM8PwE0=; b=n5H2uIlAV0gzWmxKNonLEUwRiPsDqgaMsZaWYHiWxfR+raoGE1ekXd54Cg6rlmq+eZ 5vP+FO4tBzZ1Mm5pwLUL7trN50/jxOkGVkm3Ok9JfJRWo7ocYqhJoypQdkRvS6dC8p3F 3fh3v9Zo7Sx7tlpULy8Atc1M/EJsZmG7bkgloBoiZAULU2OU2VWlB/ilR5SGssa/0xtm OJ8h3T2VcneYoI9G7FoCOgllm8asIe+4pkDymKBP7ihgBXzLmSMJ1ie8QJu+ecsiLbYq IPCKm9A3eyaNK5Ti2pMF2Kn9D3KfOr6zACXwlDpUI926hVL4fHrQrAVu02q4jPY21Zlz 6MFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TN1vD+8M; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-37337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mb16-20020a170906eb1000b00a312852bd66si44250ejb.985.2024.01.24.08.32.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 08:32:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TN1vD+8M; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-37337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8BC171F26001 for ; Wed, 24 Jan 2024 16:32:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF6F9C13E; Wed, 24 Jan 2024 16:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TN1vD+8M" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 B90D04695 for ; Wed, 24 Jan 2024 16:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706113941; cv=none; b=V1RMxpNQBkFfHloKsnk47lO2sO1T1rRihkqIHevlU83eBaFZiRIHpFf2YXh+P5LfOAA/KsK8bGvfSotTMq9NhpBbUO1+a51yuhji9QyzMRxx20SfM8S07FDWsAbBEph2HDWLmL8gFCIN/9qQnqq9Y7R1PET3HIep4+F44w+NA3c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706113941; c=relaxed/simple; bh=+zqCmFWMLWHr8Gkc0x56tIkqc6LdU6Qb3vc+IyEL5iA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nZ+TgbpeGjaMd/4DcDRBYKT/v3iOQz30O2JrMxzrk9AcBiEI3VBJ84puLt9eGmlC7pxYozR+KpA5CQ3oasioj9VUOzIUIIppcjfRj+pDt3qJ/EGeWSwK61+MNdFNDU32xeSzPAOvbzJ/+/d9taKfTi5oIocTXlwTD1k7Q61aCXs= 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=TN1vD+8M; arc=none smtp.client-ip=209.85.219.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--seanjc.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbe9e13775aso8289849276.1 for ; Wed, 24 Jan 2024 08:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706113938; x=1706718738; 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=g82foanF1CJTmaDLSQP4Ghn9FVcWHiz28lTGASp7l48=; b=TN1vD+8MPZC6fnYjgQZlBEbZ3eBtbBn096XKshKSkcci03jMpdy4KMMGHZ+mOQy7BL 29RXIlgX0bA03ia5Hm6chxI2PrQ7NqtXKfO8k0a3zXn10ZKmsEmqmpuq/dxTj6nTnP4Y RePx1/3ZJEaAQNlbLh/lv5FgDi/VdCEYhk8r9pHM4zmZ+CytG6DTc1b51n9jZlIjrb6L 96RokG7ut7qBNGHmyLD6m2GDLILecD41NWgASmVeuhmlOvxWUisXhq+4DjZ89sB+6RqW Ur6AbzijwYqNzzgGD2vG+jBfMewBXy1L5A6EKtQBBjtHaMusxWsSf0cXxGu0icuR/fty UbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706113938; x=1706718738; 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=g82foanF1CJTmaDLSQP4Ghn9FVcWHiz28lTGASp7l48=; b=Db4uIKgjhEvm0hIflW7RNP23I/6jsXStDjnRz4LCZtqhn4ywVgx7NdThiD1zaTSzug yLHHysMeZW/ZvnXnOSM+m9/T4+t6u+mX8iiHkBdZCJ7rTyXzESxy4IwieboYHFsaZwH6 cDBBCTnSHyKcoM1xS6/WhcXAf+2NQN94EEnYc9DqhsgL8GciKwvvtSBT8gPgY0GZJKlr hi69jBOXZx4dgb5eegMduanF9Fu2HlL/IJTjQ6HIJzhsmg1ij4fTfCBlpjR3nAY1FULy 55MIIs3JcaVsmpJ9gsLVqA7GuQ1aGWhIWYvpxGwwlRFVqpAlT/SL/YdHDR8diBMpYNdm oIwg== X-Gm-Message-State: AOJu0Yzj17KmzPE/o0l0x9hqS/8l2BXb2m03krPVDFj+0plPnalS9pym KO6XQcALtQQNgG+lLDLUDb3LgDdYJ7yV4gQAYQqNglSVBGGaFpr1Vo3M0MhuuFRtSFGEnFgE7YC /GA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:989:b0:dc2:2f33:bc28 with SMTP id bv9-20020a056902098900b00dc22f33bc28mr453003ybb.6.1706113938754; Wed, 24 Jan 2024 08:32:18 -0800 (PST) Date: Wed, 24 Jan 2024 08:32:17 -0800 In-Reply-To: <20240124160248.3077-1-moehanabichan@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240124160248.3077-1-moehanabichan@gmail.com> Message-ID: Subject: Re: [PATCH] KVM: x86: Check irqchip mode before create PIT From: Sean Christopherson To: Brilliant Hanabi Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Jan 25, 2024, Brilliant Hanabi wrote: > As the kvm api(https://docs.kernel.org/virt/kvm/api.html) reads, > KVM_CREATE_PIT2 call is only valid after enabling in-kernel irqchip > support via KVM_CREATE_IRQCHIP. > > Without this check, I can create PIT first and enable irqchip-split > then, which may cause the PIT invalid because of lacking of in-kernel > PIC to inject the interrupt. Does this cause actual problems beyond the PIT not working for the guest? E.g. does it put the host kernel at risk? If the only problem is that the PIT doesn't work as expected, I'm tempted to tweak the docs to say that KVM's PIT emulation won't work without an in-kernel I/O APIC. Rejecting the ioctl could theoertically break misconfigured setups that happen to work, e.g. because the guest never uses the PIT. > Signed-off-by: Brilliant Hanabi > --- > arch/x86/kvm/x86.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 27e23714e960..3edc8478310f 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7016,6 +7016,8 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) > r = -EEXIST; > if (kvm->arch.vpit) > goto create_pit_unlock; > + if (!pic_in_kernel(kvm)) > + goto create_pit_unlock; -EEXIST is not an appropriate errno. > r = -ENOMEM; > kvm->arch.vpit = kvm_create_pit(kvm, u.pit_config.flags); > if (kvm->arch.vpit) > -- > 2.39.3 >