Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4530883pxu; Tue, 20 Oct 2020 21:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS/jLRtDDHQc9niGWM4WFP0WEFbdrvF5sNDmeUJIQ3Zob/EUFaReDSXcXpLHwTlpW27q1b X-Received: by 2002:aa7:c256:: with SMTP id y22mr1172485edo.324.1603254494259; Tue, 20 Oct 2020 21:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603254494; cv=none; d=google.com; s=arc-20160816; b=A1pfAvBTnDgTAox0b7LGBicUsEW5LS9XdttgxZk7jLgdH6nERKHc7kTnet0zcY2EDM aKPYSo6ATfS383G8tRqxUvXNHmvQoF8sV/qk2zws79u+5J4ijLkxnPffS7mPBKcpJiQV GqBfxh3M+p8uBeewYln3BlCVJQf8sd6db1XtkyuWRnIeHe6moXUutV/xWnwY6Sz/z9vA 9C4ZpGgpmXj36QWpeSxBr6agtV6BO4rNBIe0Fv0j5nmkCPAxgkTJAvw3AiGqjzB1fmj6 NWk/OHmlmgamNBM4W3eEKyInGh+MAGgFrxc3EHqgWTZjKRsyxYcyqJh37kQj7gOMvUfA Ljfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :references:cc:to:from:subject:dkim-signature; bh=hjGhG7pQFy3+PaQQQ6jOV7FVy3IgvsbvzMpmnkAsMLo=; b=z+gm6n/e5t7RSV9C6dBg3j8bbgX/tEUQtQE2DsgGpWUMQI0n9sH2GrskWiEj+DqjwM v9/xQYbTj4ck6hwCkiR2drsz6/H2w51RltdZWSHciYsV4bUicVAyzEQ+6FKbzUnq3ydQ A1WO4dVlsls0PG1LyJqDotxpiMD15rSIzmnXuMCIkHjKPjeZFYOcdqBjgrIwdf3w7O9q IvEsQf2+QI6vsV8tcSSsxXEmknLJocbBTS/WBDI1HFuamHMnQ96Dm0QDHJPJyyrH8eLj hOLPgVee8UKlgXN+oN1J8hz+B3lQIt0fiWbcJkgLBE4R5vxZLbF7Ds09KXjaj9fBSb2s iytQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DzouS5r8; 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 oc24si487326ejb.530.2020.10.20.21.27.51; Tue, 20 Oct 2020 21:28:14 -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=DzouS5r8; 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 S2407431AbgJTNU0 (ORCPT + 99 others); Tue, 20 Oct 2020 09:20:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52823 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407064AbgJTNUZ (ORCPT ); Tue, 20 Oct 2020 09:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603200025; 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=hjGhG7pQFy3+PaQQQ6jOV7FVy3IgvsbvzMpmnkAsMLo=; b=DzouS5r8419NEtE86TQLhf5mwwz+XydHbgTo8NrtRHmPuiPTUN4iUl8h12oR72dkanmLU0 y8xth7BC2LuYtVwxnE/dHNncmUTzSPxuiVADp7FgcAVJk90YL9HKe0vQmb4tK2qSGrU+Fe yz8YIOfcRq4WrzIX2moxQcNYGyYnuzU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-6nnLZCC-MlSWKvHuC5o9ew-1; Tue, 20 Oct 2020 09:20:22 -0400 X-MC-Unique: 6nnLZCC-MlSWKvHuC5o9ew-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7754B803F49; Tue, 20 Oct 2020 13:20:19 +0000 (UTC) Received: from [10.36.114.141] (ovpn-114-141.ams2.redhat.com [10.36.114.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6AA61002C0E; Tue, 20 Oct 2020 13:20:14 +0000 (UTC) Subject: Re: [RFCv2 15/16] KVM: Unmap protected pages from direct mapping From: David Hildenbrand To: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Mike Rapoport Cc: David Rientjes , Andrea Arcangeli , Kees Cook , Will Drewry , "Edgecombe, Rick P" , "Kleen, Andi" , Liran Alon , Mike Rapoport , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" References: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> <20201020061859.18385-16-kirill.shutemov@linux.intel.com> Organization: Red Hat GmbH Message-ID: <2759b4bf-e1e3-d006-7d86-78a40348269d@redhat.com> Date: Tue, 20 Oct 2020 15:20:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.10.20 14:18, David Hildenbrand wrote: > On 20.10.20 08:18, Kirill A. Shutemov wrote: >> If the protected memory feature enabled, unmap guest memory from >> kernel's direct mappings. > > Gah, ugly. I guess this also defeats compaction, swapping, ... oh gosh. > As if all of the encrypted VM implementations didn't bring us enough > ugliness already (SEV extensions also don't support reboots, but can at > least kexec() IIRC). > > Something similar is done with secretmem [1]. And people don't seem to > like fragmenting the direct mapping (including me). > > [1] https://lkml.kernel.org/r/20200924132904.1391-1-rppt@kernel.org > I just thought "hey, we might have to replace pud/pmd mappings by page tables when calling kernel_map_pages", this can fail with -ENOMEM, why isn't there proper error handling. Then I dived into __kernel_map_pages() which states: "The return value is ignored as the calls cannot fail. Large pages for identity mappings are not used at boot time and hence no memory allocations during large page split." I am probably missing something important, but how is calling kernel_map_pages() safe *after* booting?! I know we use it for debug_pagealloc(), but using it in a production-ready feature feels completely irresponsible. What am I missing? -- Thanks, David / dhildenb