Return-Path: Received: from smtp.ctxuk.citrix.com ([185.25.65.24] helo=SMTP.EU.CITRIX.COM) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fNoRS-0003aj-RR for speck@linutronix.de; Wed, 30 May 2018 01:54:15 +0200 Subject: [MODERATED] Re: [PATCH 1/2] L1TF KVM 1 References: <20180529194214.2600-1-pbonzini@redhat.com> <20180529194240.7F1336110A@crypto-ml.lab.linutronix.de> From: Andrew Cooper Message-ID: Date: Wed, 30 May 2018 00:54:04 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="vH0ZjUyR0UQGqPeAEEpBhnTgDeLlZ5VSx"; protected-headers="v1" To: speck@linutronix.de List-ID: --vH0ZjUyR0UQGqPeAEEpBhnTgDeLlZ5VSx Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Content-Language: en-GB On 29/05/2018 23:49, speck for Thomas Gleixner wrote: > On Tue, 29 May 2018, speck for Paolo Bonzini wrote: >> +static void *__read_mostly empty_zero_pages; >> + >> +void kvm_l1d_flush(void) >> +{ >> + asm volatile( >> + "movq %0, %%rax\n\t" >> + "leaq 65536(%0), %%rdx\n\t" > Why 64K? > >> + "11: \n\t" >> + "movzbl (%%rax), %%ecx\n\t" >> + "addq $4096, %%rax\n\t" >> + "cmpq %%rax, %%rdx\n\t" >> + "jne 11b\n\t" >> + "xorl %%eax, %%eax\n\t" >> + "cpuid\n\t" > What's the cpuid invocation for? > >> + "xorl %%eax, %%eax\n\t" >> + "12:\n\t" >> + "movzwl %%ax, %%edx\n\t" >> + "addl $64, %%eax\n\t" >> + "movzbl (%%rdx, %0), %%ecx\n\t" >> + "cmpl $65536, %%eax\n\t" > And this whole magic should be documented. > >> + "jne 12b\n\t" >> + "lfence\n\t" >> + : >> + : "r" (empty_zero_pages) >> + : "rax", "rbx", "rcx", "rdx"); > How is that supposed to compile on 32bit? > >> +} > Aside of that do we really need that manual flush thingy? Is that ucode= > update going to take forever? I already provided feedback on this software loop, but have had radio silence as a result.=A0 The CPUID is serialisation (best as I can guess) to terminate any WC buffer which got hit, but this is going to truly suck inside a VM.=A0 If it is for full serialisation properties, the leas= t overhead option would be a write to %cr2, which is serialising on all affected parts. Other bits I don't understand are the 64k limit in the first place, why it gets walked over in 4k strides to begin with (I'm not aware of any prefetching which would benefit that...) and why a particularly obfuscated piece of magic is used for the 64byte strides. ~Andrew --vH0ZjUyR0UQGqPeAEEpBhnTgDeLlZ5VSx--