Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp690169rdg; Thu, 10 Aug 2023 16:55:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxAiELZ3NfN2Aka91A5Sbj7CdMiLUZK8PmOWkIPVgzwstMid1IQvzMJfzeN4sPGY2KzFky X-Received: by 2002:a05:6358:419f:b0:135:46d9:12f7 with SMTP id w31-20020a056358419f00b0013546d912f7mr531706rwc.26.1691711755777; Thu, 10 Aug 2023 16:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691711755; cv=none; d=google.com; s=arc-20160816; b=wwY91E54gnM23Qec+lUldv65/jH/+3Z0iReMh+XvNsPqwd2EBsyb0kaszo38oncAAX 7zLeME9nCsb0c+kqo83NaPilRgvx+65bNrTgb9sJ8wnPzQpa5JdqVKjX7d0XJ3Xsye0l u4mAlhP78ppWKgoXMWrbvzeW9TPEiRcu45FRGhM8GXibiFqXveeBsKJb40D5yDVs7umR yp8IoLrLYxKDzGcBidfkC58vCXTnsBDAC/fXCkr7ZPogecDwPBOQQvGK/FvaWPT+7f5z vkZz/UkgRfmXxSaDRdvutbkR7ENeag3aD0NfgZFHmastWxYLwzhdgIzxUdI1WpRIGo+m mRIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=tmBFxKohqxWGeEzlaaidWaFnJW/Oy/RvfXuIqafrWOM=; fh=NXSj6GOghcZpYomZIfQlTkAjl8IVzTJ+v9/gtrdHxDI=; b=eB1lgVScs+lP77xEY87t0IwTNTkaykawp74Spxvl0G0Dg8xkA5Udn6F0i0O4jhh4CB kLjJYxTWzoSCJ5tAwyGle8FOoj9UhtAZ90H5zcO+gG3PHYuUGWXOzMJQeW27s5Yd6mzJ mHGEKOHJhgNxWyahN/URnb1S4VZ5cZZa0RdPm0r5k588ASubaPMd/RjRJFuAUXEN+k2T bB+/4ENRbb0lYZJfccUqtPEU1h5CWzbvOxBV8KHoUFb9Cxia1GECV2OG9juaK93plJGd NdyWHiBESg+xZfwgcjgQQNwIt1MAhESbhuJUPfSKKcXUISfYo3XaTC/EF0hYwkuS8huA EOIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=6JTyZrfr; 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 203-20020a6302d4000000b00565700b39b8si653080pgc.769.2023.08.10.16.55.44; Thu, 10 Aug 2023 16:55:55 -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=20221208 header.b=6JTyZrfr; 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 S232170AbjHJWUS (ORCPT + 99 others); Thu, 10 Aug 2023 18:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbjHJWUR (ORCPT ); Thu, 10 Aug 2023 18:20:17 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5187273C for ; Thu, 10 Aug 2023 15:20:15 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5897d05e878so17865127b3.3 for ; Thu, 10 Aug 2023 15:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691706015; x=1692310815; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=tmBFxKohqxWGeEzlaaidWaFnJW/Oy/RvfXuIqafrWOM=; b=6JTyZrfrPMxEB4xAyKq26rEGx6dnOtJemt5mF01prNKQ3cUVfJruc7Fe7RGiRWwnTQ JNdckI2vLoo+gqpkJ4Y/rCI2rOTa5hAiAak/2PN2K2x99UdsCwMzOR99izlBg4yxVppk dQK8g/hJNDIeks6PwAz/oyY3lHetOC4GBoRbRmdSsLay+vWH0iHE9YncdP80LYWTblDI iYMvC5FUjVcDsM/OLHEHwIfhMK0QewWcYKuW2IlqTPX5Otlz706FwBUZ5hXu21vGQIT4 uYlRsQgCaSIAFf7MMqxoS33uW0RGdAOE21lmj0iEkCe384OiQkcbcQF5CJ0cTVjotCgp pMJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691706015; x=1692310815; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=tmBFxKohqxWGeEzlaaidWaFnJW/Oy/RvfXuIqafrWOM=; b=k2fT8oQ0b18vTCMH6VVpZmXUaQ+r4XnBHOYo+qjWybrL4iX1vmcdZQe7PyehMkdgyf vPmfvszNt0Xr53e9kGcYgNtcY/SeOgjD0OyHuoCrczNrdeIWkzZBUM4P81tUZcZAsfVG Tx5tL8He6PBq5xNuNrXFjVgNI5dlvqZFfe2Cx2fvsoqDtEFbVjFDcDHZvr1ZgNLD/MRT uAb/sdkjvO1rlGWk8aBqcsrF1Il1Mov4U6wQUJGERW1c0yJY6NHVpLY2tuF7HYUpd1nW eAy+RHyNfRZ7IoVb7iz1UqXJcmzIoK4NP/23MrAFpHzErof7wwvjMofnIInHMSICK2dQ xctg== X-Gm-Message-State: AOJu0YyNgDxo0xWHDF6svzDf+iB36mg4scNOUhy+ekzDIGdMkOqKgDNm Jv0VaA8B6kl2GZEsvTsGHs0XTmvGUio= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:709:b0:57a:118a:f31 with SMTP id bs9-20020a05690c070900b0057a118a0f31mr4149ywb.7.1691706015047; Thu, 10 Aug 2023 15:20:15 -0700 (PDT) Date: Thu, 10 Aug 2023 15:20:13 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230808231330.3855936-1-rananta@google.com> <20230808231330.3855936-3-rananta@google.com> <30e45ef3-309a-63de-e085-be1645c1be79@redhat.com> Message-ID: Subject: Re: [PATCH v8 02/14] KVM: Declare kvm_arch_flush_remote_tlbs() globally From: Sean Christopherson To: Raghavendra Rao Ananta Cc: Shaoqin Huang , Gavin Shan , Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose , Paolo Bonzini , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Reiji Watanabe , Colton Lewis , David Matlack , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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, Aug 10, 2023, Raghavendra Rao Ananta wrote: > On Thu, Aug 10, 2023 at 5:26=E2=80=AFAM Shaoqin Huang wrote: > > On 8/10/23 00:38, Raghavendra Rao Ananta wrote: > > >>> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > >>> index e3f968b38ae97..ade5d4500c2ce 100644 > > >>> --- a/include/linux/kvm_host.h > > >>> +++ b/include/linux/kvm_host.h > > >>> @@ -1484,6 +1484,8 @@ static inline int kvm_arch_flush_remote_tlbs(= struct kvm *kvm) > > >>> { > > >>> return -ENOTSUPP; > > >>> } > > >>> +#else > > >>> +int kvm_arch_flush_remote_tlbs(struct kvm *kvm); > > >>> #endif > > >>> > > >>> #ifdef __KVM_HAVE_ARCH_NONCOHERENT_DMA > > >> > > >> Is the declaration inconsistent to that in arch/x86/include/asm/kvm_= host.h? > > >> In order to keep them consistent, I guess we need move kvm_arch_flus= h_remote_tlbs() > > >> from x86's header file to arch/x86/kvm/mmu/mmu.c and 'inline' needs = to be dropped. > > >> > > > Unsure of the original intentions, I didn't want to disturb any > > > existing arrangements. If more people agree to this refactoring, I'm > > > happy to move. > > > > This is amazing to me. This change can be compiled without any error > > even if the declaration inconsistent between the kvm_host.h and x86's > > header file. > > > > I'm curious which option make it possible? > > > After doing some experiments, I think it works because of the order in > which the inline-definition and the declaration are laid out. If the > 'inline' part of the function comes first and then the declaration, we > don't see any error. However if the positions were reversed, we would > see an error. (I'm not sure what the technical reason for this is). >=20 > Just to be safe, I can move the definition to arch/x86/kvm/mmu/mmu.c > as a non-inline function. No need, asm/kvm_host.h _must_ be included before the declaration, otherwis= e the declaration wouldn't be made because __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS woul= dn't be defined. I.e. we won't run into issues where the non-static declaration= comes before the static inline definition. C99 explicitly covers this case: 6.2.2 Linkages of identifiers ... If the declaration of a file scope identifier for an object or a function= contains the storage- class specifier static, the identifier has internal linkage. For an identifier declared with the storage-class specifier extern in a s= cope in which a prior declaration of that identifier is visible if the prior declaration = specifies internal or external linkage, the linkage of the identifier at the later declaration = is the same as the linkage specified at the prior declaration. If no prior declaration is vi= sible, or if the prior declaration specifies no linkage, then the identifier has external linkag= e. In short, because the "static inline" declared internal linkage first, it w= ins.