Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp7414imi; Thu, 21 Jul 2022 14:37:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v6vTRZ/ezEarxeIQOK1YEpL9En6Fc1ErLwzUIRbh2TKtJJz0NRK80Pa8XwqBxZtn/hLkhB X-Received: by 2002:a17:907:2888:b0:72b:8f41:1405 with SMTP id em8-20020a170907288800b0072b8f411405mr473262ejc.564.1658439466827; Thu, 21 Jul 2022 14:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658439466; cv=none; d=google.com; s=arc-20160816; b=VSm+Z5XJbhb5HRhU7ru1FLbfg9RZu5x7Tc9zpu/eOIa4rooMPNwIW+GcqnOE4KVgGt XKeO94X8RnWZjokr8eGUgMPsZck3g7dslpMCi2nZn9ia5YXliazQ9gbj1AY4w0cuIS1a grZPmuepVTsGvKLrfFAfAxbIagG8X+RrVD1+w5dFCqtEIWE+v4mqANSURKO+jmmAxGhg KhOjjmRnEdyrSPNaqjRymTZNo97PPZWgC81lGcm35ErCGqcbp3/sAfPaDS1ZOfYcQB3h Su5xE3mf/pxTA/BWhFOaMlSZJgGnSzR5yatNGRCWJvE3nMWfTZ5vtOSvrQlkOL+yle9y Z5Mg== 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=11OqmbhSRizQ74Ch/j9J4lE0a0EnvcFlYhbfmnjs8Cg=; b=HqHNKeTha4FIes9MWjATpUgi8LrKviZ1iZxSKjb2PpHtvM2TII7vY/joY9k89ldzIM 9oIST/Fbk7SvXlbzSmmxLaZWXfPlBlRHD9BfM8T/rrPA0ul/pK+R1C50AZm68h9gXyMp HapV+Zo0wYQ85P16o8tRfZUhs9aoX7koC6oFmQE892fwbKpsvpLtRqNO9Tnz/MQshmI4 hjfgYjxf/fkWt5YC++AMEabgGYCzdcc7vAaT1hx51aoUpOlcjJRxBYrXdRjo0ZHgCIat 1A5CeHdE5vm73IYbrQ3H37VsqbR4rBEZFsePI/j03YOlf4etv0En+svI45IMjsVAoL19 DBlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="RenZ/SKd"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf29-20020a1709077f1d00b0072ac7db91e6si3868721ejc.610.2022.07.21.14.37.02; Thu, 21 Jul 2022 14:37:46 -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=@google.com header.s=20210112 header.b="RenZ/SKd"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233749AbiGUVQW (ORCPT + 99 others); Thu, 21 Jul 2022 17:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233780AbiGUVQR (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 2EB31664D0 for ; Thu, 21 Jul 2022 14:16:15 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id f65so2756975pgc.12 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=gjzTucS22J1P7qGZc8M9m9EHTIOuIMavrZfHBGItygGIxOlUj7ZZ3ScLQh1axKnZZ8 alVTd5VMxrzQnilNhVxqq9iDgkZFi48VaD32a9jeqBUdRvl3j8pl5ZbvsjmnPCxgODkz feYGB1Bra01aiWRfUZwZIE9mOwHRYPFMlz9rkNrE+9EkJnKzvNbi6iXENhNT1irC61xb y+/LfRqxrQzJSg6LtfGJxN+2U8OagvyNs1sjuILT+yzG7Z6DzXV1JXUk44/fi6Vn5nSO /vJJFPP34Pgtfk4R69/RsHIGRY6S9XNMqBLC6Haqs4wGwTM6Aei4tU1Q1t9bq/I5cV/Y om3g== X-Gm-Message-State: AJIora/1vAvAYLe3NHb4f22FwJpEyWYftdtmemONKR1opqN0T3ueP2j3 cBK1ZnbCvkgdQCK870EUZgfXmQ== 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: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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, 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.