Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8772398rwi; Tue, 25 Oct 2022 10:34:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5tHQlNf49BcEAXt8NIgR4hn9jrUH/FLBBAnEar+D+RDaw6Ch4dSvB1xLru+byRTEu/tpFG X-Received: by 2002:a63:c142:0:b0:43c:9fcc:c9f2 with SMTP id p2-20020a63c142000000b0043c9fccc9f2mr33343052pgi.44.1666719246615; Tue, 25 Oct 2022 10:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666719246; cv=none; d=google.com; s=arc-20160816; b=phQOwbRr9bfpiCpaXingSztU7PqjzbjW5Hky5Lyl+9W2pHorLGeYgddGRnVDEk/0VE w3Gb0p5yz/xdxYmoIEdY6sH32DTLMjPQxeBjbLvUz7hHqEhJkiVCfu8GK3xegI2i503H fRUAgmp3QNwD/Izlsr3GOgkYINho3DK47zhMr2I+bX1Lctgsdusm7eq+IxeBOEFby1cv d5XnHgzrk0dxTfB2xuGgK2+Xbx67v5TCW2cTV1rR20qDV4xzMMHc9Dmmqrqd0ZXTzQxf WGyPSoEiMpkyuBQ6FWD6hRFm2u9QxgIiEnqLn5nOPZGvs4YJqahQk/Eq5LnKXhrzY/uz aIbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=du1ODIVzDVk6wmvqQAobisUJiOuA6OOoA0oy9u/yWR4=; b=Y+vcbtowfdSEf10xYYUiNc+pvwgMJDpP/lJnQcc5UXtB9XSJKVohgrkJDA/bm40nx9 8NtLuS4X5ay2UVdYapANBWgqpWGa3UgfyVqYPNtFVhauHT3x5roEwmmaZQ4xkIDxmYw6 XK5FqqqKkz8VIUeVlD1opBZhjxjDOZtf3FCN6Een1sqJmQdx9n5dj7/XP9UdZ56A/jiQ Z73yO2gQC1TE52f121w6rEa9H96UkXB2bZm5unP4DthySLEEHowY+zEry+5nfMRPS5EK QhG8no683WyOFnounSagI1bZSqwqhfI6sHokO0d0i9p1yqKA4exZweAhsUkhlwMzxj7t p16Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=syIE1vRJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om17-20020a17090b3a9100b001fdb95c743bsi14011610pjb.83.2022.10.25.10.33.54; Tue, 25 Oct 2022 10:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=syIE1vRJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbiJYRVL (ORCPT + 99 others); Tue, 25 Oct 2022 13:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbiJYRVJ (ORCPT ); Tue, 25 Oct 2022 13:21:09 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 395EDDBBE1 for ; Tue, 25 Oct 2022 10:21:09 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d24so11536838pls.4 for ; Tue, 25 Oct 2022 10:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=du1ODIVzDVk6wmvqQAobisUJiOuA6OOoA0oy9u/yWR4=; b=syIE1vRJPa3K5k0d8UDqEvr3g8RMzSiY/aQ/i35eYRA/jVA6bkeDhz64mSRp9GHnja 3lgRnMrV/SxoQaJYuJychgOhQvJ7xDq7fP8QSY6aF8AZ1eWqtO8EANBHZKNq7dSxBFGh suMo6Sr9qIEH2C3oxfW8XbKxGFj2nsA287g/+oFyJ+Nyt4vjjmrQS23t6YSYloTskpHV rF94Vv/+UuBVV+p5E7gKB3PdvqpW9ch/rsKdimJVwum415XeDIl3oJ8bjU87b0tRHiKo +pRKWAoge5JBnsuECpAZi6MtktM9Ckv6p68/bGLgZ+G5HON7i5Xg0cTWzUuQAr8Oz+8W UnEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=du1ODIVzDVk6wmvqQAobisUJiOuA6OOoA0oy9u/yWR4=; b=BszYU1aD6u5GgL8MmbdJsMkgH0tlbA3fIbXF5GXGmRybGTtSvJnMGwKb5lC0OzoBhY dh7/uLKlj17VEXU0PV75a/hqN2dhkmPWXQj8A6AL7j8AvJnIZ6r4wC6PYygeux868D8p nHrviNrOldzL3p1NDT/ubj/kVkAJCFc54ovT+JWrVdR/SvycMI26nY4yq9Uw2UQK9xeR DD/hvX5/c7+cnVNcdsUJRB23vCTfqet9KYtqEdpmkeF86n91sMP2qrVYrZpTi4xzWm/z xpsSxp24vdsin1u7oiXtxWr+9QZkyrrtdOWOWTlVqu5tG5po//fzAHWLJR5iNnkeVthu IWng== X-Gm-Message-State: ACrzQf2yZDhm8wIQ6HUWq9vngDY/7uM8hlOvI6TcrNqlrfzc6sBLaYS3 kmTmLPzV5Uz0nIlDfv6e3eNXig== X-Received: by 2002:a17:902:ccd1:b0:186:5ee4:cf49 with SMTP id z17-20020a170902ccd100b001865ee4cf49mr30766395ple.26.1666718468613; Tue, 25 Oct 2022 10:21:08 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id z24-20020a17090acb1800b00212d4cbcbfdsm1608210pjt.22.2022.10.25.10.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 10:21:08 -0700 (PDT) Date: Tue, 25 Oct 2022 17:21:04 +0000 From: Sean Christopherson To: Emanuele Giuseppe Esposito Cc: kvm@vger.kernel.org, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Bandan Das , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] KVM: vmx/nested: avoid blindly setting SECONDARY_EXEC_ENCLS_EXITING when sgx is enabled Message-ID: References: <20221025123749.2201649-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221025123749.2201649-1-eesposit@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shortlog scope is still wrong, should be "KVM: nVMX:" The shortlog is also somewhat is misleading/confusing, as it's not at all obvious that "sgx enabled" means "KVM's sgx_module param is enabled" and not "SGX is enabled in the system". E.g. KVM: nVMX: Advertise ENCLS_EXITING to L1 iff SGX is fully supported On Tue, Oct 25, 2022, Emanuele Giuseppe Esposito wrote: > Currently vmx s/vmx/KVM > enables SECONDARY_EXEC_ENCLS_EXITING even when sgx is not set in the host MSR. "sgx is not set in the host MSR" is ambiguous. "sgx ... in the host MSR" could easily refer to the SGX_ENABLED bit in IA32_FEATURE_CONTROL, it could refer to the ENCLS_EXITING bit in the allowed-1 half of IA32_VMX_PROCBASED_CTLS2, etc... In other words, please be more precise. This statement is also wrong in that it implies that KVM _always_ sets ENCLS_EXITING, whereas the bug is purely limited to nested virtualization. E.g. Clear enable_sgx if ENCLS-exiting is not supported, i.e. if SGX cannot be virtualized. This fixes a bug where KVM would advertise ENCLS-exiting to L1 and propagate the control from vmcs12 to vmcs02 even if ENCLS-exiting isn't supported in secondary execution controls, e.g. because SGX isn't fully enabled, and thus induce an unexpected VM-Fail in L1. > When booting a guest, KVM checks that the cpuid bit is actually set > in vmx.c, and if not, it does not enable the feature. Again, this is nothing to do with the failure.