From patchwork Thu Oct 12 16:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13419418 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3516FCDB482 for ; Thu, 12 Oct 2023 16:13:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.615914.957457 (Exim 4.92) (envelope-from ) id 1qqyIs-0003CR-UR; Thu, 12 Oct 2023 16:12:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 615914.957457; Thu, 12 Oct 2023 16:12:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qqyIs-0003BY-RI; Thu, 12 Oct 2023 16:12:50 +0000 Received: by outflank-mailman (input) for mailman id 615914; Thu, 12 Oct 2023 16:12:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qqyIs-00039J-0i for xen-devel@lists.xenproject.org; Thu, 12 Oct 2023 16:12:50 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2f5c8eee-691a-11ee-9b0e-b553b5be7939; Thu, 12 Oct 2023 18:12:48 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9ad8a822508so192351966b.0 for ; Thu, 12 Oct 2023 09:12:48 -0700 (PDT) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ci24-20020a170906c35800b009a2235ed496sm11414461ejb.141.2023.10.12.09.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 09:12:47 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2f5c8eee-691a-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697127167; x=1697731967; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=m324SzpB4tRrNifTcRyeznzQLigWiB6PcnuW2+zuICA=; b=NLxdhPFzKozxRqzCDwaBPDK5+ciYKuuU5fKrbY5WLqxhGLJ+M517ca1JaaVw/BoelN 2RY4VibWkvkD5fRr03aEjFo7RzismvQDu1/aYA7+QQaOTKIx08PuLWHG4nj4kOdeB73T wMIwOvSqMNeuZBEk2EXbJyWRrNu+y2XtgvG7pXLUHmb1IphPUcHdu7yWYmcZVQa8UhF5 aXHHR8yE8QhB/CdEsejgYefwZfLyvKzvLr40MJ3jBAEfYoBlLfBB2pb4evLTo4B1GE4V Z7M6Q1+IjzTWchZlI2zJ4+F1Z+0lXHpZB1voBQh14t8GR54NwWomNMfd7+fZzBYwv4Dk yDbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697127167; x=1697731967; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m324SzpB4tRrNifTcRyeznzQLigWiB6PcnuW2+zuICA=; b=B9L8/g7Xhg3cCmRulQ4/uiqa11ZuB0BsSmnP3M7S0dIBfTCR9yQNwnmAyyvtXy2cC2 Rcj3arDZrZyklWQyUQFERgyEPiKFTY9yOQ/BVx368Khgpfny67bPyhaNgA0dvrx6AOxy vpqLqOiZEo28UxlyhKoCDcXEd/XC9WJ5yrp54OcM86hPJ1MvQxUD9ocxSjpMhV8SQNpS PeQt7hQGiPO3/OiJTcQ24grCAP7zh3cykMzA3JIrDeib/4/R7pmeAPwz67jwixdBAxTw GZO/2z1dDxcB2fUQTVs8C3VS8ea5DAQZJCA7KZbGRUJhLZkRltd/hSDNjI3lmmJbu8m3 mclw== X-Gm-Message-State: AOJu0YwphKpq9gPJXw+DFSeykrL1kJjGqKEaejMZt84nT2TUKv10hgPe FvKenAsnmGPTtmrIgJvOXF8= X-Google-Smtp-Source: AGHT+IG3OATQwvAdDylZaY+NQE8rIqD1qHAB+PgGQkf9k1iPsawqa69X3y4KQT9BWLEr8K6NDqfqoQ== X-Received: by 2002:a17:906:290:b0:9b2:89eb:79b5 with SMTP id 16-20020a170906029000b009b289eb79b5mr24236684ejf.35.1697127167247; Thu, 12 Oct 2023 09:12:47 -0700 (PDT) From: Uros Bizjak To: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH 0/4] [PATCH 0/4] Introduce %rip-relative addressing to PER_CPU_VAR macro Date: Thu, 12 Oct 2023 18:10:35 +0200 Message-ID: <20231012161237.114733-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 The following patch series introduces %rip-relative addressing to PER_CPU_VAR macro. Instruction with %rip-relative address operand is one byte shorter than its absolute address counterpart and is also compatible with position independent executable (-fpie) build. The first three patches are cleanups that fix various inconsistencies throughout the assembly code. The last patch introduces (%rip) suffix and uses it for x86_64 target, resulting in a small code size decrease: text data bss dec hex filename 25510677 4386685 808388 30705750 1d48856 vmlinux-new.o 25510629 4386685 808388 30705702 1d48826 vmlinux-old.o Patch series is against current mainline and can be applied independently of the ongoing percpu work. Cc: Juergen Gross Cc: Boris Ostrovsky Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Uros Bizjak (4): x86/percpu: Use explicit segment registers in lib/cmpxchg{8,16}b_emu.S x86/percpu: Correct PER_CPU_VAR usage to include symbol and its addend x86/percpu, xen: Correct PER_CPU_VAR usage to include symbol and its addend x86/percpu: Introduce %rip-relative addressing to PER_CPU_VAR macro arch/x86/entry/calling.h | 2 +- arch/x86/entry/entry_32.S | 2 +- arch/x86/entry/entry_64.S | 2 +- arch/x86/include/asm/percpu.h | 6 ++++-- arch/x86/kernel/head_64.S | 2 +- arch/x86/lib/cmpxchg16b_emu.S | 12 ++++++------ arch/x86/lib/cmpxchg8b_emu.S | 30 +++++++++++++++++++++--------- arch/x86/xen/xen-asm.S | 10 +++++----- 8 files changed, 40 insertions(+), 26 deletions(-)