Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 02 Jul 2018 23:44:15 -0000 Received: from mx1.redhat.com ([209.132.183.28]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fa8UP-0006eU-Kf for speck@linutronix.de; Tue, 03 Jul 2018 01:44:14 +0200 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1E38308FB9D for ; Mon, 2 Jul 2018 23:44:06 +0000 (UTC) Received: from washington.bos.jonmasters.org (ovpn-116-137.phx2.redhat.com [10.3.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A76E1D7175 for ; Mon, 2 Jul 2018 23:42:41 +0000 (UTC) Subject: [MODERATED] Re: [patch V5 03/10] KVM magic # 3 References: <20180702154426.910579106@linutronix.de> <20180702160528.728959353@linutronix.de> From: Jon Masters Message-ID: <4a49512c-6fd7-8a43-c1df-c5169bb9feb3@redhat.com> Date: Mon, 2 Jul 2018 19:42:39 -0400 MIME-Version: 1.0 In-Reply-To: <20180702160528.728959353@linutronix.de> Content-Type: multipart/mixed; boundary="hSg8KQC6MMdFJnNB7YDqJC65zmmaYIKxz"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --hSg8KQC6MMdFJnNB7YDqJC65zmmaYIKxz Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 07/02/2018 11:44 AM, speck for Thomas Gleixner wrote: > +/* > + * Software based L1D cache flush which is used when microcode providi= ng > + * the cache control MSR is not loaded. > + * > + * The L1D cache is 32 KiB on Nehalem and later microarchitectures, bu= t to > + * flush it is required to read in 64 KiB because the replacement algo= rithm > + * is not exactly LRU. This could be sized at runtime via topology > + * information but as all relevant affected CPUs have 32KiB L1D cache = size > + * there is no point in doing so. > + */ > +#define L1D_CACHE_ORDER 4 > +static void *vmx_l1d_flush_pages; > + > +static void __maybe_unused vmx_l1d_flush(void) > +{ > + int size =3D PAGE_SIZE << L1D_CACHE_ORDER; > + > + asm volatile( > + /* First ensure the pages are in the TLB */ > + "xorl %%eax, %%eax\n" > + ".Lpopulate_tlb:\n\t" > + "movzbl (%[empty_zp], %%" _ASM_AX "), %%ecx\n\t" > + "addl $4096, %%eax\n\t" > + "cmpl %%eax, %[size]\n\t" > + "jne .Lpopulate_tlb\n\t" > + "xorl %%eax, %%eax\n\t" > + "cpuid\n\t" > + /* Now fill the cache */ > + "xorl %%eax, %%eax\n" > + ".Lfill_cache:\n" > + "movzbl (%[empty_zp], %%" _ASM_AX "), %%ecx\n\t" > + "addl $64, %%eax\n\t" > + "cmpl %%eax, %[size]\n\t" > + "jne .Lfill_cache\n\t" > + "lfence\n" > + :: [empty_zp] "r" (vmx_l1d_flush_pages), > + [size] "r" (size) > + : "eax", "ebx", "ecx", "edx"); > +} Per your request explicitly reviewed the above. Jon. --=20 Computer Architect | Sent from my Fedora powered laptop --hSg8KQC6MMdFJnNB7YDqJC65zmmaYIKxz--