Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1027491pxp; Sun, 20 Mar 2022 04:09:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxftwGtfwP6W9kIouxLIM0Jri5ZPn6hhT1atK3Lr5+11jYvQRS/gRtsR7L6dSLhxWQ3dWwv X-Received: by 2002:a17:906:7312:b0:6db:5729:f11 with SMTP id di18-20020a170906731200b006db57290f11mr16109031ejc.623.1647774599133; Sun, 20 Mar 2022 04:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647774599; cv=none; d=google.com; s=arc-20160816; b=zXkXAsAJxzpsbkMANaIhZa8ErqKTTDM0/dy+Wm9IwKNa9cd3Bpl0rsFyQuJ23qvbA7 PB0FTLPGJkw5K9pq53mnsVdmEY4rdqGLVPYCNJtwOoqa6+ol0ShVj7k4MtlyjBttWQvd hzw9doBjVmRtNeqergDBFWgxwVjRGLQHRJE5QUZFofqigM9WD/nWV2BlHxi/fMjUMtJv 38eH8Jb/Sh7QbwppPcxLQchMkEz6NtUT5IvmYO1wxw1r4whFxUaoN6S7tx5IXJ/MVCmb EyJ3lYyq4RPRRgoDLWEw3MOWl4IGKIOOK3bGwb5vXpghVHVFo8wYWvwSWyDGv5JWoqLp ODzQ== 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=7cHjZTrO3pszQOYs78HUK2TVdaR3zSuUmPa3P4965TQ=; b=KwEQjc4cZpLZQ4Z3vOxNeGoU6WA3ZIoPtKmA/tlE1aiCEpQvbv8jrt3uoqN7WtXmlm 9QZY7ZZ/mnxSpAeCqAZ9afyGWREa6qOgEkkG0mkGZ4vjI1m4SxkVgibKSGVkbtVLjpfV dO7h0D9O6lZZcZZUXHISRMNN0USH17RVMDgR5F6qIDFfLzxC2wk92VYIH9rSr0C2p53R CVCeYn6ut1R0v3NieMLY/IAaDRll4LwLOlhiCxC4Nefo6BnfpmNv37lzKWQxa1xioGld skqhpKuK9HmhyzSVUFovKK8P2Wvmfc92VMESxzoscLTib/+GETDISLyo491qLoca4hUN 7HsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=VeMn+FV7; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tc26-20020a1709078d1a00b006df76385d3fsi3964194ejc.479.2022.03.20.04.09.33; Sun, 20 Mar 2022 04:09:59 -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=@alien8.de header.s=dkim header.b=VeMn+FV7; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235798AbiCRLay (ORCPT + 99 others); Fri, 18 Mar 2022 07:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235789AbiCRLaw (ORCPT ); Fri, 18 Mar 2022 07:30:52 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC661ED055; Fri, 18 Mar 2022 04:29:32 -0700 (PDT) Received: from zn.tnic (p2e55dff8.dip0.t-ipconnect.de [46.85.223.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id B26241EC0662; Fri, 18 Mar 2022 12:29:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1647602966; 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:in-reply-to:in-reply-to: references:references; bh=7cHjZTrO3pszQOYs78HUK2TVdaR3zSuUmPa3P4965TQ=; b=VeMn+FV7lsd7524c97/dvErpkObi38LUan9DkmodjZQSeYnUrvs7EaaJuXn0hK/BI/NLtz 62womwRZey5rcx+VkO/8LsSXpmzNml/SwXDz2Iadftaplf3xGftTClz54F7KSC9VsZD5lo KwtZsPVedAcImMNQwD6wjo7iSXsPItg= Date: Fri, 18 Mar 2022 12:29:23 +0100 From: Borislav Petkov To: Joerg Roedel Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Dave Hansen , hpa@zytor.com, Joerg Roedel , Tom Lendacky , Brijesh Singh , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] x86/sev: Unroll string mmio with CC_ATTR_GUEST_UNROLL_STRING_IO Message-ID: References: <20220310112615.31133-1-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220310112615.31133-1-joro@8bytes.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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, Mar 10, 2022 at 12:26:15PM +0100, Joerg Roedel wrote: > From: Joerg Roedel > > The io specific memcpy/memset functions use string mmio accesses to do > their work. Under SEV the hypervisor can't emulate these instructions, > because they read/write directly from/to encrypted memory. > > KVM will inject a page fault exception into the guest when it is asked > to emulate string mmio instructions for an SEV guest: > > BUG: unable to handle page fault for address: ffffc90000065068 > #PF: supervisor read access in kernel mode > #PF: error_code(0x0000) - not-present page > PGD 8000100000067 P4D 8000100000067 PUD 80001000fb067 PMD 80001000fc067 PTE 80000000fed40173 > Oops: 0000 [#1] PREEMPT SMP NOPTI > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.17.0-rc7 #3 > > As string mmio for an SEV guest can not be supported by the > hypervisor, unroll the instructions for CC_ATTR_GUEST_UNROLL_STRING_IO > enabled kernels. What I'm missing in this description is why wasn't it a problem until now? You mentioned something about libvirt adding TPMs and that causing this but I'm still unclear as to why exactly this is causing the issue. I'm guessing SEV guests didn't do string IO but libvirt adding a TPM is somehow causing them to use them now... > @@ -56,9 +55,8 @@ void memcpy_toio(volatile void __iomem *to, const void *from, size_t n) > } > rep_movs((void *)to, (const void *) from, n); > } > -EXPORT_SYMBOL(memcpy_toio); > > -void memset_io(volatile void __iomem *a, int b, size_t c) > +static void string_memset_io(volatile void __iomem *a, int b, size_t c) You can simply remove that wrapper and use memset() at the callsite. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette