Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5833032rwe; Tue, 18 Apr 2023 12:13:29 -0700 (PDT) X-Google-Smtp-Source: AKy350bAmt3eRbshQpbzJFO+Lby4Y4aCHZU0rIp4+Ckn5xqJYLBdGpy6Fi9RtmaykyXJVdxl7UZP X-Received: by 2002:a17:902:e0d2:b0:1a6:c81d:5f4d with SMTP id e18-20020a170902e0d200b001a6c81d5f4dmr2192585pla.10.1681845209166; Tue, 18 Apr 2023 12:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681845209; cv=none; d=google.com; s=arc-20160816; b=xq/PMMUA3LVg+FmHoeRZtm2WZ4M0cNJu1HiWxU4Y2jOgGpbyDB6iDbZOXpBNyyH6/d 7qPK1lscpuw0q2EE7kz9htw3bVwGL6R9fuj4F6cjmozNGn+WzhMAya8uzhduzPR2cVqE XXDbo7f5U+ly7ki0gVSbxY9AKmtGbklc47+2C021lfS15cIF18ndNqmfZhq3Ynvjxup0 J8qJcBF9k6/lo74CQ1bXiXkvRbXhppGGj6ryrGtBCIIEfEJ4eE5vrWfthacqp5irsajB RauIZibi6ujFMsM4bMrSIfzk0X64O0oLWQEOMeRQFp6L40tylNLcByzDXa6/DGXGWyqv A2TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=iNinZ/xtW0ZVHNrwkVxIEbNSe13fqzLdKKr8yvRoE6Q=; b=gU7tDFG9NEQco1x2owyJAHO7i6wjI4KsOpqudZncCYtPhi6vLqb6qp7HBN8H5zdkp5 NfD4auIvtddoQR1BSEo2y+CS/LYXBsp6ssg+abddMoEa7Xovt45fkcqaw/AW4CGMjUKK G/bhLVe06aThEUfBI8Rrjg9QcHA3F+kjDayj9Blkg1J/kkWnKw5NGiLKJpAjPBfSx9dz sPxHLKdtVudsQMEhWq6iEyVjcc1J39JV5YC20iScqyGrWYGXHWy5Njuv4ZrFJ6fIJs5X 63ix/FYWipWaJMYjKyNX53Bk+s4V8NAvpzq8eRQtYPdStFULQtHeIq6qelJo6DPIEah0 1K6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=5KSRwCuw; 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 a7-20020a170902ecc700b001a6a3954e0fsi11304663plh.18.2023.04.18.12.13.16; Tue, 18 Apr 2023 12:13:29 -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=20221208 header.b=5KSRwCuw; 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 S232791AbjDRTJ0 (ORCPT + 99 others); Tue, 18 Apr 2023 15:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232742AbjDRTJX (ORCPT ); Tue, 18 Apr 2023 15:09:23 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D55A7AAE for ; Tue, 18 Apr 2023 12:09:07 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-552f169d85eso45050047b3.13 for ; Tue, 18 Apr 2023 12:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681844946; x=1684436946; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=iNinZ/xtW0ZVHNrwkVxIEbNSe13fqzLdKKr8yvRoE6Q=; b=5KSRwCuwMyrWMDBBcG/2qLwTpPHtKAMowKCiYtJuWD677A0UXbzGo0q/j1L9X2nkwT /hhHbfJnm7Hqc+akjWuhWRfRa9Di+SCcPtKhuNFFSh05wLVH16h4SPITGgjk/DNdCSav lDRw53gtqwSId6DXnuqEewZ1QZWZ/+ev5ui6QrZ5DX3dQiis0PHO2QaM9DoOAhSFWT2n 97KqM+M6HutWEDT3mcSJj+RhKc+hH7HL76NKsWUUidq7mkr7yfKaWBWGKGRKm9w8lxeP cYc2zt9hH+9Iug0bGJn4nX08OFaWQREGVYhcO+nHeVZenJS4Tqxuz6zoajfhTyCE7bW2 vwYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681844946; x=1684436946; 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=iNinZ/xtW0ZVHNrwkVxIEbNSe13fqzLdKKr8yvRoE6Q=; b=DAO/1Op3bMm29upjh+tprLnowkbLR5RySSyJWPVMmRC6QW09FaERRKkrxpTCMxeoTW ACSBaHUDAJq0in0g+3pMTJ8G3wDYzmnaqlRzxqiLqoELJnAnXqLzbqX50qzA56ILDfpp uR0dp790DzfzCVTrHxVpqAD+ZewFl2XzDHMS1TdV0DGTeTWmrfOeGUGCXy8gl/qXv9ER 84Q3yOoHS4xdVeSEJf6AbYIXkOzQwfRABliJF9ijVRkjw1nvvQRJ0MKldtaWsyRsKSO6 9R6L3+0EZ69Sw03ojGUgkaYk8cI0BDLNZhBmsFVhEGOinfko5PMx2NYKAdVMzzVxen6Y YqPg== X-Gm-Message-State: AAQBX9cXSX/W3PhAB1Mo98+d+GLcfoI0UgNnUZ671r/7cJ9euP+wfOgq a9WYxY0PqYpcU2XhJDMNBd8vDdCXEC4zT5UM X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a25:cf4c:0:b0:b8f:47c4:58ed with SMTP id f73-20020a25cf4c000000b00b8f47c458edmr12907520ybg.9.1681844946790; Tue, 18 Apr 2023 12:09:06 -0700 (PDT) Date: Tue, 18 Apr 2023 19:09:04 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418190904.1111011-1-vannapurve@google.com> Subject: Re: [PATCH v13 098/113] KVM: TDX: Handle TDX PV map_gpa hypercall From: Vishal Annapurve To: isaku.yamahata@intel.com Cc: dmatlack@google.com, erdemaktas@google.com, isaku.yamahata@gmail.com, kai.huang@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, sagis@google.com, seanjc@google.com, zhi.wang.linux@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 > +static int tdx_map_gpa(struct kvm_vcpu *vcpu) > +{ > + struct kvm *kvm = vcpu->kvm; > + gpa_t gpa = tdvmcall_a0_read(vcpu); > + gpa_t size = tdvmcall_a1_read(vcpu); > + gpa_t end = gpa + size; > + > + if (!IS_ALIGNED(gpa, PAGE_SIZE) || !IS_ALIGNED(size, PAGE_SIZE) || > + end < gpa || > + end > kvm_gfn_shared_mask(kvm) << (PAGE_SHIFT + 1) || > + kvm_is_private_gpa(kvm, gpa) != kvm_is_private_gpa(kvm, end)) { > + tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_INVALID_OPERAND); > + return 1; > + } > + > + return tdx_vp_vmcall_to_user(vcpu); This will result into exits to userspace for MMIO regions as well. Does it make sense to only exit to userspace for guest physical memory regions backed by memslots? > +} > +