From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79AC5C433EF for ; Thu, 21 Jul 2022 21:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233773AbiGUVQV (ORCPT ); Thu, 21 Jul 2022 17:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233749AbiGUVQR (ORCPT ); Thu, 21 Jul 2022 17:16:17 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8505C347 for ; Thu, 21 Jul 2022 14:16:15 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 6so2751326pgb.13 for ; Thu, 21 Jul 2022 14:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=11OqmbhSRizQ74Ch/j9J4lE0a0EnvcFlYhbfmnjs8Cg=; b=RenZ/SKdXZfOHNevGxkMopwKMPWrfJxiCyc9BeId33rQlF1/1vzAERKsROGsgu73PO 3Vh+kBwRBR34zv6Cs7ZDNkRpWgwILWeqJwmR13cSjtmU0unAVdR41Nf/NH0jfEogkr2r JHF9df+/fhRXMvvJnH3igBuCM+wK+xZhIdC/GSM24+Vcw7Gc90w73jNaPXTXhKdfuYLT Dku2YQ2CN5mLe0SZz1eF0QJrwRspDs0R8NQZXQX7+lxV0WzhKtPvY+5ITZxdh5gN/3r+ nMFKRwOUV1v2Cq34kX1X0GD8LegMqzy3ApouqelaYdqEVdaSzVtSegGXRc/6GHjh0zKx /wJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=11OqmbhSRizQ74Ch/j9J4lE0a0EnvcFlYhbfmnjs8Cg=; b=u1j0fs0qVVLHuinf+GdcfGRyVIpVf20WzxfEKb891tCnQYtPgJEemwNhVFya9VkDEK tRzbsqG+CwENvxFZUGtgUBnj986fsJoevLgVjFHys+grENQNKBofsrzFIiAvZLQRoa8N jIgsfglDqDzVlP/lscEg0J+CeTJoV1+Ik6zeR7Xd8Cp7lqGbj4pMU1HN74XqKlAwe0em nn8nm+HTAYFF2nxv9Eg042ES88+b26aRyFJ4V8dlOzPYAxytUGdt4WB6yMFqyvsZH8um pfPO5yxG97jcLeJ7D9JAdUQP1qB/PxrogA1OVL1hlK09WBB1Jbi02povIHJoccISO7Dk 7zRg== X-Gm-Message-State: AJIora8WFp3JqBoYiXMQWKj88ptD1ZFzO6LdyAsjLGLSsUk9Kgpz3rtz 4zLyj8tn4owebBR7GJIOwjR70u9JuZ6YZg== X-Google-Smtp-Source: AGRyM1tYVnSFtctc/PTPJVmFsiWSfHQt3N50JGg4333C9oMWtUgpVYWuQQYd9+YZX+C2GpeXrgjMVA== X-Received: by 2002:a65:6151:0:b0:412:e419:d651 with SMTP id o17-20020a656151000000b00412e419d651mr289868pgv.378.1658438174487; Thu, 21 Jul 2022 14:16:14 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id h6-20020a056a00000600b00528c6c7bf37sm2213407pfk.129.2022.07.21.14.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:16:13 -0700 (PDT) Date: Thu, 21 Jul 2022 21:16:10 +0000 From: Sean Christopherson To: Vishal Annapurve Cc: x86 , kvm list , LKML , linux-kselftest@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , dave.hansen@linux.intel.com, "H . Peter Anvin" , shauh@kernel.org, yang.zhong@intel.com, drjones@redhat.com, Ricardo Koller , Aaron Lewis , wei.w.wang@intel.com, "Kirill A . Shutemov" , Jonathan Corbet , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Chao Peng , Yu Zhang , Jun Nakajima , Dave Hansen , Michael Roth , Quentin Perret , Steven Price , Andi Kleen , David Hildenbrand , Andy Lutomirski , Vlastimil Babka , Marc Orr , Erdem Aktas , Peter Gonda , "Nikunj A. Dadhania" , Austin Diviness Subject: Re: [RFC V2 PATCH 2/8] selftests: kvm: Add a basic selftest to test private memory Message-ID: References: <20220511000811.384766-1-vannapurve@google.com> <20220511000811.384766-3-vannapurve@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jul 21, 2022, Vishal Annapurve wrote: > On Wed, Jul 20, 2022 at 4:03 PM Sean Christopherson wrote: > > ... > > > + * which doesn't handle global offset table updates. Calling standard libc > > > + * functions would normally result in referring to the global offset table. > > > + * Adding O1 here seems to prohibit compiler from replacing the memory > > > + * operations with standard libc functions such as memset. > > > + */ > > > > Eww. We should either fix kvm_vm_elf_load() or override the problematic libc > > variants. Playing games with per-function attributes is not maintainable. > > > > I will try to spend more time on how kvm_vm_elf_load can be modified > to handle GOT fixups in different scenarios including > statically/dynamically linked sefltest binaries as I currently recall > limited information here. > > But modifying kvm_vm_elf_load to fixup GOT entries will be > insufficient as guest VM code (possibly whole selftest binary) will > need to be compiled with flags that allow memset/memcpy > implementations to work with specific guest VM configurations e.g. AVX > extension. Same concern is outlined in > https://elixir.bootlin.com/linux/latest/source/tools/testing/selftests/kvm/lib/x86_64/svm.c#L64. > > Would it be ok to maintain selftest binary compilation flags based on > guest VM configurations? No, we should instead define/implement versions of memset/memcpy that are guaranteed to be guest-friendly, either explicitly by selftests are implicitly by compiler builtins, e.g. see arch/x86/boot/string.h.