From patchwork Wed Dec 9 13:17:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11961361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC0FFC433FE for ; Wed, 9 Dec 2020 13:19:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E916207C8 for ; Wed, 9 Dec 2020 13:19:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E916207C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZNYRskgzxQvuLs3XLzV/7uuxkYmG1Fzv/SwutKOJstk=; b=scmDuTYRjzrBiFKB29wJiOHL7 59wWcQsggtNs2Bm+v+7ocxbUm9yWXm9ZAav+cfc9eC63rXBudPiLgUhMLhZmPN5oc11W31On7NzaB merS8FwgNBEPzRVWcgApUq9rpfV2OAHKfVGs6jXv7Vxn+jIEpDXYKY8XCgtR2gagzLFWQQtURNgTD Uab4cpDsrlIcrQTAW1+6JfQzjoc4mvQdBCBn5Qwq2XjLHZ/L1vLalaAT5Rf6vDjT4gNfYq/vE744V 6BbGyO0Q+Dao1rcnqYCiYDgHGUJv4TgBw0ZJwPh5L8Rxh0WUbB5Ujm8lzKjsJi9lYBKcqlR77GSG9 2umD9lDEg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmzLz-0003CR-1f; Wed, 09 Dec 2020 13:17:59 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmzLt-0003Ar-Fu for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 13:17:54 +0000 Received: by mail-wr1-x441.google.com with SMTP id x6so1698028wro.11 for ; Wed, 09 Dec 2020 05:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ui2AyYakjARNpvT610MmpwVISaykxIjU1EziL4bq/8g=; b=TtPn5gbE5cUnZn/XoZAH5Q1SPuX8zUYSCs/O66h6C9BXK3fpK/Gxba6BH70xbSUMQI rysLsdyUKSLybXMLAMuifFTOgm/GYv7CzvMxgqTkJEp1Fzljb4N/quSYihWIbdHGfOMS YewS6M/7CjC7YsdpjGCrrDdk6y4EyOkTNlena25qIj6QWnxi/8p/lfEfwkgi6UyCbeb6 sjUB6nqC+Uxvz6IBGuj5pn76G9Dt2QO8PEqw5mKADfHfuFpx49k489ssqc8jcB5yU5iE ahnxDbrtLwfx8ViQriceqefi2FsulHCF3546sTznByZRVN57V5UzPws2FuRb/mBmH1Xt 6yQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ui2AyYakjARNpvT610MmpwVISaykxIjU1EziL4bq/8g=; b=AJyn6Fl9GR93DrrGXAEEY67N6gnWvOIR2v36E/r757gtxzky3IwAm/oDYqkalt7cac Xa1niMtv72ULF82rmE0LJH2dQWNm7SuPW6IuXM+fP9NLgbjrbeZU6rb40cvlJ9FJjM9y Fr3HUyrecgVlT02JPyKGbJKo5uouR8cW4G69ysYvjHskbs4W+hiSv8mHuT7bJ/D98oQd ZUZLWdorwtzc0OwAs9NWfnTDnYn0c3i10KjRcGKShAbHaFi4QhKG0ISNDIWYq9ES8VB3 05SOQswBMDPLXBbmCxN6OjKqEW5qltMSRXXYVF0w4eHMReOdFsvXeVokRS24hWjesklz BKNw== X-Gm-Message-State: AOAM532D01OKuQyeSoeuUXaP1TAuP6l8fjmDWcVlkrZtEUfMZqTSCCGB BZ9IZscDZSP5/14StZunndybpA== X-Google-Smtp-Source: ABdhPJzlT1ZAQI8+iYY8fpTcJpj5l6KBwxxqgFiRZRdWFROI/wunQbz/voXHfXAhUBU4AIC7QtIReQ== X-Received: by 2002:a5d:5146:: with SMTP id u6mr2832541wrt.66.1607519872306; Wed, 09 Dec 2020 05:17:52 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:9d1b:d0eb:db43:6cd2]) by smtp.gmail.com with ESMTPSA id g192sm3294480wme.48.2020.12.09.05.17.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 05:17:51 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 1/9] KVM: arm64: Correctly align nVHE percpu data Date: Wed, 9 Dec 2020 13:17:38 +0000 Message-Id: <20201209131746.85622-2-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209131746.85622-1-dbrazdil@google.com> References: <20201209131746.85622-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_081753_551516_721C2D81 X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Suzuki K Poulose , Catalin Marinas , Jamie Iles , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Will Deacon , Ard Biesheuvel , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Jamie Iles The nVHE percpu data is partially linked but the nVHE linker script did not align the percpu section. The PERCPU_INPUT macro would then align the data to a page boundary: #define PERCPU_INPUT(cacheline) \ __per_cpu_start = .; \ *(.data..percpu..first) \ . = ALIGN(PAGE_SIZE); \ *(.data..percpu..page_aligned) \ . = ALIGN(cacheline); \ *(.data..percpu..read_mostly) \ . = ALIGN(cacheline); \ *(.data..percpu) \ *(.data..percpu..shared_aligned) \ PERCPU_DECRYPTED_SECTION \ __per_cpu_end = .; but then when the final vmlinux linking happens the hypervisor percpu data is included after page alignment and so the offsets potentially don't match. On my build I saw that the .hyp.data..percpu section was at address 0x20 and then the percpu data would begin at 0x1000 (because of the page alignment in PERCPU_INPUT), but when linked into vmlinux, everything would be shifted down by 0x20 bytes. This manifests as one of the CPUs getting lost when running kvm-unit-tests or starting any VM and subsequent soft lockup on a Cortex A72 device. Fixes: 30c953911c43 ("kvm: arm64: Set up hyp percpu data for nVHE") Signed-off-by: Jamie Iles Signed-off-by: Marc Zyngier Acked-by: David Brazdil Cc: David Brazdil Cc: Marc Zyngier Cc: Will Deacon Link: https://lore.kernel.org/r/20201113150406.14314-1-jamie@nuviainc.com --- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S index 5d76ff2ba63e..1206d0d754d5 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -13,6 +13,11 @@ SECTIONS { HYP_SECTION(.text) + /* + * .hyp..data..percpu needs to be page aligned to maintain the same + * alignment for when linking into vmlinux. + */ + . = ALIGN(PAGE_SIZE); HYP_SECTION_NAME(.data..percpu) : { PERCPU_INPUT(L1_CACHE_BYTES) }