Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp802500rwb; Thu, 4 Aug 2022 11:08:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR47+LScfgH44ARiYvwpmiRp3w7eqnoAxLinfLQ7M6fPbqovrmE/JGhNQl4icuR9bafN+Pfu X-Received: by 2002:a63:6406:0:b0:41b:f291:2cbf with SMTP id y6-20020a636406000000b0041bf2912cbfmr2659279pgb.96.1659636508453; Thu, 04 Aug 2022 11:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659636508; cv=none; d=google.com; s=arc-20160816; b=yWgRcMrh2an2c9Mmu6oAyiqB9iYH/jV+aUcsEJAGiYXk8CQNQvJAWxnY7wHbpHiW0x XcewR5ymxDeiK7uVoyDFnOIkA0pn8xvltvJ6c55XyWXC+4wNVHRHhu+2Q/mAvt7gXRfU S0GwT12Ze0/4YqlF+wQLXgMrojZehbUzaMcHLaCpj3EIh+u7XD+Zmyd9NrUYuRL0sRNL WEJPu9WqTBlT4CaMCDMgqpgrl+OKd21W7viS09a8Y5f1KNnsPOQzUsPv4NDMRKQCjpb4 y8fy3Cm6vrueIsXjgCkbPppyf28f+pprqyxSEK9gJxThah+uKS2ossLMF+Ht2gBRCS/y EVXg== 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=I+2klbPtMg8JDmNlmkLOfkLK7UdOD2bPaKewB5S493I=; b=Q5I+DFzQ9Jq9kibVSY+af/DbXd+UEaNoWNz3byNwI9K+boDkrs4bljqZNptgSa3jE4 1Kbpz3Bb3EckYUqJnXhvKn/bwFAX1MACBztnbTiDPDr0u4n1u3M6kLYC0I9OA97HOeh8 mMnnJwHZq45AarMekX+y0SR7fwzUxItclf1XGVu82BsWk+VMTWB6XCATDAzQQ+F1opOi jIdBCxv6iIAknG/DJ5TYUWCCjEuNqDfbjSSKaG2qCGla0lwTe/0Kv9Gw8HV0dJ8nh9Qc GKHL8cmQTQo4c+LZOIKmU/M9EWL6JcquMfFhbm6dlCQ/8N2SbHY9xRnTBF7VLMo5PR25 VKig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JWRc8lpz; 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 u10-20020a056a00124a00b0052893a7c620si1727548pfi.276.2022.08.04.11.08.12; Thu, 04 Aug 2022 11:08:28 -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=JWRc8lpz; 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 S239266AbiHDRmT (ORCPT + 99 others); Thu, 4 Aug 2022 13:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234299AbiHDRmR (ORCPT ); Thu, 4 Aug 2022 13:42:17 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EB3C67CA6 for ; Thu, 4 Aug 2022 10:42:16 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id ha11so442430pjb.2 for ; Thu, 04 Aug 2022 10:42:16 -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; bh=I+2klbPtMg8JDmNlmkLOfkLK7UdOD2bPaKewB5S493I=; b=JWRc8lpzmI1XPDrZdYpOkOaHGJM9cuJ6S36qN6rCIkka1D+pCnjBmWL2QpgE58pchQ Y8hetXvTbbN4FGz9bTRUf5auA47ghrM+ozLswJ5TfKY7AoeM1GvCh8KepCnQJXvTlGeL c91qNyGukSxvdUOhw0mStLikLlq5FvEcWa12peKE/HYibXsvRKJkjKLn5fuKHI8e14TJ tJX4azNySy7c3fVDb1DtoDw1GCvA703nGeQMJ+74ydgW6ujkD/Zg2ho+694ShFqYEw4F 1lHb1H7JbUkptA0PWqduIT+12ebhOD4kZWJ6JIZ1GPyD9FD8Mx0K6fzBX28aYJa6jikG p+ow== 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; bh=I+2klbPtMg8JDmNlmkLOfkLK7UdOD2bPaKewB5S493I=; b=Kpt+zFIY3blAo8mTshnEXNJgz32of0kyqu7OlP3TMevp+wp9BF5fdekmCbZSfhK/SW zcBojoXP29gcLWFxi1kK/ypxC1mhMDRDRU23Gh970G5cmyqewraZBAgZoAMpBZ/diMcp 7+Cnc9K9wUAhsrEIDGTVBI+Qf4uff/qBgmYIVTPs9pOO4zLLVkhkqe+6qkEbQ1eWkoLc Qv/az9PUwCbmtulCqqd/rEpyLWvYv/lBOLBoJsATX6QaGHzjEzJBc4ndi+neoWAvEQ3L M6KuhgcIdmy9B2RiujjhoQuODLFFKUV4vAzGgMlFrH5VgBz3icMrhnno3l+Vuz3uoldj 06xA== X-Gm-Message-State: ACgBeo2J7Qy9wjYFiXlC0y1eP0DabcdEm3Qz/T8i50lPKHcAafocy/VA 8SZTC7Wpn6eMG0Keww51XU6V8Y5fknGDIQ== X-Received: by 2002:a17:902:cec8:b0:16f:8081:54bc with SMTP id d8-20020a170902cec800b0016f808154bcmr2833466plg.139.1659634935635; Thu, 04 Aug 2022 10:42:15 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id w79-20020a627b52000000b0052c0a9234e0sm1359044pfc.11.2022.08.04.10.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 10:42:15 -0700 (PDT) Date: Thu, 4 Aug 2022 17:42:11 +0000 From: Sean Christopherson To: "Dr. David Alan Gilbert" Cc: Vitaly Kuznetsov , Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Dave Young , Xiaoying Yan , David Woodhouse , stable@vger.kernel.org Subject: Re: [PATCH] KVM: x86: revalidate steal time cache if MSR value changes Message-ID: References: <20220804132832.420648-1-pbonzini@redhat.com> <87v8r8yuvo.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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,FSL_HELO_FAKE,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 On Thu, Aug 04, 2022, Dr. David Alan Gilbert wrote: > * Vitaly Kuznetsov (vkuznets@redhat.com) wrote: > > Paolo Bonzini writes: > > > - gfn_t gfn = vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS; > > > - > > > /* We rely on the fact that it fits in a single page. */ > > > BUILD_BUG_ON((sizeof(*st) - 1) & KVM_STEAL_VALID_BITS); > > > > > > - if (kvm_gfn_to_hva_cache_init(vcpu->kvm, ghc, gfn, sizeof(*st)) || > > > + if (kvm_gfn_to_hva_cache_init(vcpu->kvm, ghc, gpa, sizeof(*st)) || > > > > (It would be nice to somehow get at least a warning when 'gfn_t' is used > > instead of 'gpa_t' and vice versa) > > Can't sparse be taught to do that? Hmm, it probably could, but the result would likely be a mess. E.g. anything that shifts the GPA on-demand will require explicit casts to make sparse happy. This particular case is solvable without sparse, e.g. WARN if gpa[11:0]!=0, or even better rework the function to actually take a @gfn and then WARN if the incoming gfn would yield an illegal gpa.