Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp733045pxb; Thu, 21 Oct 2021 08:28:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2o6tSue/iZEtEdOgt9pnqnaZ9xs6/kK9fFZT9DpWH2hnO/tdVOSOrLwWF8WiZDgqq4R4i X-Received: by 2002:a63:6f4c:: with SMTP id k73mr4972614pgc.61.1634830115127; Thu, 21 Oct 2021 08:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634830115; cv=none; d=google.com; s=arc-20160816; b=yBSkAMWsU0drmqDHhRQETjmGtWdRIRby85EY9FYFoF2lfVNCObIpZk9N9EWpKs79lN IqrPd+MOWNyyWW8hkVzTl/Uq9sb5jl7Uo9kjx+pRaiR5BfMogNx3g/0qn+lsbQqa01Dt CcQYHPxPS4yIlzheHS2Ga1Rhqf/vBH3lM+QihowinMHbWJPRBrPiPLGb3wYCPGyVgLD2 vbTYg5OJN8Z6VobvA5aavG9A2AO8ZsIDSX4ofn7nt30h7Cgb46M33IqXngbPa9APXTMJ 0HkChFKrV51WCe8Ln/u06AuLb1KoGq7D9PBZI3Mfy4YK9inImz1Cl0NHikQe2CXpkCKc Ab9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=v6MrzrO7xesFuLzBcBSeQQGfqugRLLAD0yJI9mSpS6E=; b=TasLKIzdUt7ziddMSB38fr3T97ObzJFmz5uQRjOz0g6kqemGYY1mCETxVJxanW+sdC +LDsGYiC31GHEIQp0JMZhPJ8f4CjH1ATWKjt/b9MH0LpF56tfI/aqyp+AbwMP6RM/cFD sFZqARJY+VRK1XG5JxXXRaUPvrnErNBQswdWIjd0lkisdPOt0f0qCCNllry2q0eJsaUI uvDEXyDWZdxU0nnoVCb9xSwrRtIzqf4TtGC5045JY93Vt70CQkdqtc7txdGY5PN1DTOc brb1PhiySaIGfgILvAOZfJQnyWTy9urWNG2JM2oPhtHfXun4LOfhGknNmJ7hEFS3eO3o 5WYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ir6wvnX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si8686875plg.382.2021.10.21.08.28.22; Thu, 21 Oct 2021 08:28:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ir6wvnX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbhJUP30 (ORCPT + 99 others); Thu, 21 Oct 2021 11:29:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52591 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231880AbhJUP3Y (ORCPT ); Thu, 21 Oct 2021 11:29:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634830027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v6MrzrO7xesFuLzBcBSeQQGfqugRLLAD0yJI9mSpS6E=; b=ir6wvnX99ZtXjqIg4nol7R4+RPf0al6SNNMSmG+YYIT7qpPwvCbV3KN137qPM+GLwhs8Ae S86vB4qN8fD5EEo/eJ+AQDulU1fMQ7UvOlVXSgWIUQ5FYHNiYDyqfCvsZFMHLKQy0G1ebK G/sakayu4B4X2iMWxi7Ij2ZY9dPGN1s= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-IKIjoSekNpCzdzwS9AT8Ug-1; Thu, 21 Oct 2021 11:27:05 -0400 X-MC-Unique: IKIjoSekNpCzdzwS9AT8Ug-1 Received: by mail-ed1-f70.google.com with SMTP id v9-20020a50d849000000b003dcb31eabaaso719186edj.13 for ; Thu, 21 Oct 2021 08:27:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=v6MrzrO7xesFuLzBcBSeQQGfqugRLLAD0yJI9mSpS6E=; b=7t6Fhy5Citewv0Mo2MPm3PmrCBmkEUUk4GAd49nE4hEXmJuaHEoqfo5F61JR7rGdQr OClabnOXGHRwub9C20Q457rU3XOwU61fGKfjeCq8Th+4BgUT4LIJuhF33sYy8rn2I4V/ lbMlB6Qn+Uo1fK2DdhRwfFMFCFKFnQQZ7Rsl+LFvewNix08Ek98Abw3qAXGAOnc0jkoe +UNAKT+t7XsCi1bPuALToA4FvjZeub7SwqamqcZM5lDMUBfs87fZ0qIpdYQFzZfWSbqX 8nLEjNkefz+9AAOhfbWkMDy+weRa1f96glTB/1WIl3R/4mRbAY/BlWIjd9JqgreBMC6n hkSw== X-Gm-Message-State: AOAM530p9d8egvBFSwIi1zlPrzblLwK594WeL/M2si6fTbGEvY7WtNPI 5yTDVGbprm+Yvwz+0svYqr9IxvQHpOZS+a9H/b2/viv9V1/9Az10Ee6iAIbMgMeDoNb3Cku9Ard wXN20O0VBW+1o3a8ziix6Rwg7 X-Received: by 2002:a17:906:4fc8:: with SMTP id i8mr7830762ejw.342.1634830024439; Thu, 21 Oct 2021 08:27:04 -0700 (PDT) X-Received: by 2002:a17:906:4fc8:: with SMTP id i8mr7830743ejw.342.1634830024244; Thu, 21 Oct 2021 08:27:04 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id o21sm3003991edc.60.2021.10.21.08.26.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 08:27:03 -0700 (PDT) Message-ID: <31db4c63-218a-5b26-f6ed-d30113f95e29@redhat.com> Date: Thu, 21 Oct 2021 17:26:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [RFC 03/16] KVM: selftests: handle encryption bits in page tables Content-Language: en-US To: Michael Roth , linux-kselftest@vger.kernel.org Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Nathan Tempelman , Marc Orr , Steve Rutherford , Sean Christopherson , Mingwei Zhang , Brijesh Singh , Tom Lendacky , Varad Gautam , Shuah Khan , Vitaly Kuznetsov , David Woodhouse , Ricardo Koller , Jim Mattson , Wanpeng Li , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" References: <20211005234459.430873-1-michael.roth@amd.com> <20211005234459.430873-4-michael.roth@amd.com> From: Paolo Bonzini In-Reply-To: <20211005234459.430873-4-michael.roth@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/10/21 01:44, Michael Roth wrote: > SEV guests rely on an encyption bit which resides within the range that > current code treats as address bits. Guest code will expect these bits > to be set appropriately in their page tables, whereas helpers like > addr_gpa2hva() will expect these bits to be masked away prior to > translation. Add proper handling for these cases. This is not what you're doing below in addr_gpa2hva, though---or did I misunderstand? I may be wrong due to not actually having written the code, but I'd prefer if most of these APIs worked only if the C bit has already been stripped. In general it's quite unlikely for host code to deal with C=1 pages, so it's worth pointing out explicitly the cases where it does. Paolo > @@ -1460,9 +1480,10 @@ void virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr, > * address providing the memory to the vm physical address is returned. > * A TEST_ASSERT failure occurs if no region containing gpa exists. > */ > -void *addr_gpa2hva(struct kvm_vm *vm, vm_paddr_t gpa) > +void *addr_gpa2hva(struct kvm_vm *vm, vm_paddr_t gpa_raw) > { > struct userspace_mem_region *region;