From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D553CC433B4 for ; Tue, 20 Apr 2021 20:16:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AD21613C0 for ; Tue, 20 Apr 2021 20:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233806AbhDTURU (ORCPT ); Tue, 20 Apr 2021 16:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbhDTURT (ORCPT ); Tue, 20 Apr 2021 16:17:19 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 971DAC06174A for ; Tue, 20 Apr 2021 13:16:47 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id q2so2076476pfk.9 for ; Tue, 20 Apr 2021 13:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=baguO7314vCrN8/3Lvu6Ck0/6YUj93gK/SeIRlHPkHY=; b=VDk6YLqqHBjXELr908Vy3WBsu/P3T1SUqT+ZE+rHFrt/R8+YWT9gMDUBRfkEmzdvrH n2heHViq5NBoovkpWFoJ9szOnoaDxi0rQNrCxGxXw+go42e2mkquPT5Kn1c7hw/UZGAK SHxReazCEAgCJd3ktuLdhBRBu5hNh4DOGBm+1lIe0NjGPMbcR3KZQ0w/f8nrgB+CX5Uz wItuzAE2l0q92ZY28tv0EmYCx4IIh8LSjN8Xrz7J8Wg9OTlhyUTGoTonMJLfygkOTxxl JiloQ2+INXgN+FVI5Bc65zkU3dsdO9rQc4jouA3KmoeAT339FhlBhZmIyKqljJqnbQDt fDeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=baguO7314vCrN8/3Lvu6Ck0/6YUj93gK/SeIRlHPkHY=; b=TncF0FKlxbED+EAzFE438RjxKBLCdp1AfWSYfrOTWOkZPwjnfh+wh9b+NhW/Yko/pd DZVy02/P8+/yPzxLtyxzs2iGVxXvTVAVP783M4lKaHiPK7woaNBC/1OmF+Xy1x9xn63w MV/T/plBsMc96qE58T37NlCRTVyb9dZHG6faeA08PG7tk9PgG7LzcbiLgHsXuHAmZN/m Lc9vbpS2HgxJL7vThBc2fy04wFB3AqV+xXqyhRwFjz4nlDbIwW6uIqDcl5JcCCHkwl2b YUCQspmSgJ1+sdVn/pYbFdGRneef3e1CS3gXs8h/fmogF4J8NkJVhQGqOx6bw9eYnqpk iEuw== X-Gm-Message-State: AOAM533jYjtmyjUGdfxh6yzobnzlMgH2YPXpMFvgxmDHyE8BrCB/NrjN iY2pcSUHgTmEoRaowjUXui4Cjg== X-Google-Smtp-Source: ABdhPJzHP5mB0IkvpDfWhhTGznEdghO0p6TOY9+Gmafh1xpRpiI1fIGjEWEv/6LcbyNjpPa6ucTahw== X-Received: by 2002:a17:90b:1955:: with SMTP id nk21mr7031347pjb.198.1618949806996; Tue, 20 Apr 2021 13:16:46 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id k15sm16500650pfi.0.2021.04.20.13.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 13:16:46 -0700 (PDT) Date: Tue, 20 Apr 2021 20:16:42 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, srutherford@google.com, joro@8bytes.org, brijesh.singh@amd.com, thomas.lendacky@amd.com, venu.busireddy@oracle.com, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , x86@kernel.org, Ashish Kalra Subject: Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration Message-ID: References: <20210420112006.741541-1-pbonzini@redhat.com> <05129de6-c8d9-de94-89e7-6257197433ef@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 20, 2021, Sean Christopherson wrote: > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > On 20/04/21 19:31, Sean Christopherson wrote: > > > > + case KVM_HC_PAGE_ENC_STATUS: { > > > > + u64 gpa = a0, npages = a1, enc = a2; > > > > + > > > > + ret = -KVM_ENOSYS; > > > > + if (!vcpu->kvm->arch.hypercall_exit_enabled) > > > > > > I don't follow, why does the hypercall need to be gated by a capability? What > > > would break if this were changed to? > > > > > > if (!guest_pv_has(vcpu, KVM_FEATURE_HC_PAGE_ENC_STATUS)) > > > > The problem is that it's valid to take KVM_GET_SUPPORTED_CPUID and send it > > unmodified to KVM_SET_CPUID2. For this reason, features that are > > conditional on other ioctls, or that require some kind of userspace support, > > must not be in KVM_GET_SUPPORTED_CPUID. For example: > > > > - TSC_DEADLINE because it is only implemented after KVM_CREATE_IRQCHIP (or > > after KVM_ENABLE_CAP of KVM_CAP_IRQCHIP_SPLIT) > > > > - MONITOR only makes sense if userspace enables KVM_CAP_X86_DISABLE_EXITS > > > > X2APIC is reported even though it shouldn't be. Too late to fix that, I > > think. > > > > In this particular case, if userspace sets the bit in CPUID2 but doesn't > > handle KVM_EXIT_HYPERCALL, the guest will probably trigger some kind of > > assertion failure as soon as it invokes the HC_PAGE_ENC_STATUS hypercall. > > Gah, I was thinking of the MSR behavior and forgot that the hypercall exiting > behavior intentionally doesn't require extra filtering. > > It's also worth noting that guest_pv_has() is particularly useless since it > will unconditionally return true for older VMMs that dont' enable > KVM_CAP_ENFORCE_PV_FEATURE_CPUID. > > Bummer. Oh! Almost forgot my hail mary idea. Instead of a new capability, can we reject the hypercall if userspace has _not_ set KVM_CAP_ENFORCE_PV_FEATURE_CPUID? if (vcpu->arch.pv_cpuid.enforce && !guest_pv_has(vcpu, KVM_FEATURE_HC_PAGE_ENC_STATUS) break;