Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp59220rwb; Thu, 17 Nov 2022 20:30:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ZpnoECZQMBPlBlKW7KWErRwr5MSrlEVGTGBbpSpHGEZWi2ipWbPPU4MsEPbzCowWd0yHL X-Received: by 2002:a17:907:2bde:b0:7ae:4a7f:3280 with SMTP id gv30-20020a1709072bde00b007ae4a7f3280mr4628304ejc.265.1668745845640; Thu, 17 Nov 2022 20:30:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668745845; cv=none; d=google.com; s=arc-20160816; b=WjQfSGXPfsn0rtHu8upFyY5EuOn4G/w20Ro0JGd5E8Szky+aTuyBNbK5qHZkAwaRha /XmLVHRqAwr1ocfq8WDZDdo3SIDM7NE6eclL6RjNnH7KQj+HPmWJahz0NhHP2wASbtlI FqYQ7bXQ5oRgxS4qnRsBTH+wLG9dh4BXaRYuQAgmX4GFH+feLBv71kYvjIRsHDR8xV9b 9NMO7gQ6K0tLrJBqIwU8rqytUn2j4ZkD7CaWMGH8IZ/jzP4/A7o1BWUPNSeGRiWXnpWs CG2NpTTI+xt4G7A7QJ70+GQTrKswwRAhi5n69ZVvA2QNENcI2Aaua5kX80eoJJZ51zXi 4ESw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CgJUQemp/f+PlGTIq0YX+TmFg52HbYStJmaJzWE+VoY=; b=Mu3MiKdvLGxVJXBDkG0C1ge7WI+eK23FlfuBZb5P+gsFmwKvC5TImrvGMR2ixxh8fM +s3SjHsX2w9IZT7agQZJaBbanF/6FqFovqHDjB3FOCFccFLkjDo/aSD0IH8veL5jn4IQ cx8W45AZaG68J1aEg3uPqd1vClMe+NvjyZAaQHKgrjh6gA8ETZ+nBtg4PNGXLucyPPI9 t7jOU/5bNk9iHfJ/SoxV8qZDizF0X0A87U6gYuyJsxrTN3CcPEEP3+z6FR3yMwlEiRHq 9oQum4lXko6Gfc2/+d0xJH8NIpIEyEafTtIOLG7iSC3PefASfaYO9hquPhBM/Lf3PTR6 9X2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SUp6Yqzg; 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 fk26-20020a056402399a00b0045d4f99616dsi2276765edb.456.2022.11.17.20.30.22; Thu, 17 Nov 2022 20:30:45 -0800 (PST) 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=SUp6Yqzg; 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 S240499AbiKRDtk (ORCPT + 91 others); Thu, 17 Nov 2022 22:49:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiKRDti (ORCPT ); Thu, 17 Nov 2022 22:49:38 -0500 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38EF48F3F5 for ; Thu, 17 Nov 2022 19:49:38 -0800 (PST) Received: by mail-yb1-xb34.google.com with SMTP id i131so4267633ybc.9 for ; Thu, 17 Nov 2022 19:49:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CgJUQemp/f+PlGTIq0YX+TmFg52HbYStJmaJzWE+VoY=; b=SUp6YqzgYosJg+/9xNr+ggz5uHPqyABf5MdSAdKEofxZMLjOt8dv0Jcuovgcob651q CehG6KAzs2YhjA+aySdFOf7G93Ve+A5GupCsUFU/1HrODmB0uDS2+c79Jxbb4qIZdhv3 /HbU3RnOZSNzwVe5rOZ3REc9NGP81flOV2TZsVNvoAtLEJbVHWLrZspdbPbwBs20ELjV IRw9+DZ+TAj3hMy3tYemVZ8p1521IzydCHJLXlKiBypchCNaVWP1zFTv9v4D3qK0/ln7 8pEoNRP+MKFZMTghx0dTL4sEPo7b+HkChabyinzS8m8JSn2LTvK+PFLwRIeOzjjbWA4H gwBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CgJUQemp/f+PlGTIq0YX+TmFg52HbYStJmaJzWE+VoY=; b=bpvdj8zs7cft1g75ru+dJ9wvEGEen9LKEZQtggOsw2+REhyQZqtfFfYjf3rhaZQ5Xx lk6TEhicXwby72+CuT7pBlUmqbSggRw02SOz3Mtj2u+stq3ayCnoVwHE3l7F/wOeiWzX 6i7PGZ7Wmr5SS7fODeCDSHVF5Tklt8BT8LzZfMsZTBRoNQa8A7Q6Kk6nTq9HSgFxIIEd q4SWZm4PNRGGLSmdzxMXcBMtHxBQxJP2Kw9IwPlZWD3w/6g2y9nQjaTdkXyTWdehoyzI xzwGu/xvBJG7Zd/BQImL5NSdHWulTEYU6EQiu8D5ttx58u1hlxKAo3PabUicw2OMF3UT Siow== X-Gm-Message-State: ANoB5pnOl5D3t7Q37Mrq6AVp5/qXkJ7SBhF18FMHwWr7eosxANLVAqPw naG2ap+vnW7WlKqtjzIoA+XQf/5nhpyuhq2BInYbUg== X-Received: by 2002:a25:ae12:0:b0:6d0:704:f19f with SMTP id a18-20020a25ae12000000b006d00704f19fmr5330087ybj.191.1668743377371; Thu, 17 Nov 2022 19:49:37 -0800 (PST) MIME-Version: 1.0 References: <20221117161449.114086-1-pbonzini@redhat.com> <11f5e652ca2c2a4507316c3426b25d0d5cd66120.camel@linux.intel.com> In-Reply-To: <11f5e652ca2c2a4507316c3426b25d0d5cd66120.camel@linux.intel.com> From: David Matlack Date: Thu, 17 Nov 2022 19:49:11 -0800 Message-ID: Subject: Re: [PATCH] KVM: x86/mmu: simplify kvm_tdp_mmu_map flow when guest has to retry To: Robert Hoo Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, seanjc@google.com Content-Type: text/plain; charset="UTF-8" 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 On Thu, Nov 17, 2022 at 6:01 PM Robert Hoo wrote: > > On Thu, 2022-11-17 at 10:43 -0800, David Matlack wrote: > > On Thu, Nov 17, 2022 at 8:14 AM Paolo Bonzini > > wrote: > > > if (is_shadow_present_pte(iter.old_spte)) > > > - ret = tdp_mmu_split_huge_page(kvm, &iter, > > > sp, true); > > > + r = tdp_mmu_split_huge_page(kvm, &iter, sp, > > > true); > > > else > > > - ret = tdp_mmu_link_sp(kvm, &iter, sp, > > > true); > > > + r = tdp_mmu_link_sp(kvm, &iter, sp, true); > > > > Can this fix be squashed into [1]? It seems like a serious enough > > bug. > > If 2 threads race to update the same PTE, KVM will return -EBUSY out > > to userspace from KVM_RUN, I think. I'm not sure about QEMU, but that > > would be fatal for the VM in Vanadium. > > > > [1] > > https://lore.kernel.org/kvm/20221109185905.486172-3-dmatlack@google.com/ > > > I think in you patch it's all right, since then before > kvm_tdp_mmu_map() returns, it must go through > tdp_mmu_map_handle_target_level(), it returns RET_PF_* enum. Ah that's right. kvm_tdp_mmu_map() won't actually return 0/-EBUSY, because it either returns RET_PF_RETRY or goes through tdp_mmu_map_handle_target_level().