Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp785419imm; Fri, 21 Sep 2018 08:15:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZw0Yg7kOzjJm7qk4F7gkXnhPZyhkl5RXuk2ujiUQGxh4voj+HtWZRBjnK/hXESfe0snVgQ X-Received: by 2002:a62:9c17:: with SMTP id f23-v6mr46950117pfe.209.1537542944399; Fri, 21 Sep 2018 08:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542944; cv=none; d=google.com; s=arc-20160816; b=ynf389h9IIz/4M8tWhx8WZpxN38drEdmE4kW5hWpAxwY6SsINgkffBZpObNzCIiSxL OhrANakwDMOdrXGwSzNuW3CqRExivnvBRJKKL5n4mk/RZ/S/wwyU5fZF55rOHX81GUEQ cQeeqA1aEND0pSiMVLV5EzQA+02+XQ4VyiFlKCO4lKbtxp6wp+2tbyWuweuNKe++Yhkd UZw2FwnS7s2234m1bdoxKWrsXOO0/Q72ZVm5kOXTLoK93NnSCgLK+Y3twoFitApJXwcp 5vcaYTtSrclTIguXH7dTvI9ds1xt9wyLbNyj7zegGp4HzXfB/ZtsxUoGtogB625U7V9w Juew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=myc+iFznG+xU2oejuTstHBw/z6FAJlgaorRzD++lkYI=; b=JAVJhQPgJJkBN06NMfa4Yn/8Oktc5DR8QmCSQRTov8NMULyQRpCOwK5mR+M4nqKTTZ CCVKS/LhlaItj0y29x1LvBmxoZTh7KzBW1OOzF40WYMhkREMwv8P/BxM84eqgaj3a9RC aRW6hHbrz75ivsyau1s2Bu7wNNjaY+nFT+uMeMfpbWwg0DuYqcmlZGZsCb8MKQqH9yfM cu/3FijvFGbplYjvR6QsjC6lMDIiPIgvTCdA5eL8PKaqT7UBScaDvfyi5sJJXmj08Q3p f0DmPEaI8719mh6+xRFyhCD8wpR9lJ9DEof1Xe/RN6T7yuny9YwClylADu33xA/+gdRP Ugjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aZ3Qh9II; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si28184985plq.316.2018.09.21.08.15.18; Fri, 21 Sep 2018 08:15:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aZ3Qh9II; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2391034AbeIUVD3 (ORCPT + 99 others); Fri, 21 Sep 2018 17:03:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41557 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391024AbeIUVD2 (ORCPT ); Fri, 21 Sep 2018 17:03:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id j15-v6so9141828wrt.8 for ; Fri, 21 Sep 2018 08:14:08 -0700 (PDT) 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=myc+iFznG+xU2oejuTstHBw/z6FAJlgaorRzD++lkYI=; b=aZ3Qh9IIBfUdiC+v6Lry7v+8dlK7URGA46gmKYpAQlMNaT516kCSIAAKxRRuxuFboM BxdWeWXxImYKZp/HHAV9d008RCV7Jg2zj2BtpLhBe0iiiXa0YlCUq90LpHv8aACNq/un frrfI0QQp6y09aziMs+FxKP0lRGNo29fPuPtt/mc/1POP7H2q3pEqr3CbgOoCxE/kCxQ wU2fX7V9FnhyLDUM6s8vbA8x/5mrruy8spwUxgcn8eXyUnnmfaefsIR4XRNAnzQ7rENA HCi8QyxD0ZeHSQnkMKqQ+VuiHtNmOR7M5XN2SVHzrupCkbSurat1YkFKqVudo1DltvdP ayrg== 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=myc+iFznG+xU2oejuTstHBw/z6FAJlgaorRzD++lkYI=; b=spFG9dNyVVL9jKxLKd7g1bdxbapxGqKZ15ZlDp4GabvQ2gMlykkGLH2jPoMItPdu1q Kc7jQi2MbgR6EoQc2BNARpmrdqc/TDcPF6snx359DbWDn6kP4oESGgyGrBhZBbnkUaNq VQTSt5rLPnMckw+Ck9M1MMIt5z6s2+Wma7AtVnU4arndmwAfv/mqb1ZY4Ix90qqz1thg 8IjxQNkBIU+qnMh7TWGvZJTYf67bQp8zdk35C+0Y5BEqMQsniprEw0sYazheZyflbi4g uR2kPxd94gzdfCmRw9TI8HqLxvVstFdJLOydk8AuA/bjf8D9YZ2Ibk6bfzEGfCzS9u5b zzGQ== X-Gm-Message-State: APzg51A6miZjrzJLmM4MT6HFAW+GOd2fmOo8ECzyLQHEeRs9ls6n+gYL SVSA225SFn/t+J8+x/x7w+BQQA== X-Received: by 2002:adf:a4dc:: with SMTP id h28-v6mr26625905wrb.167.1537542847324; Fri, 21 Sep 2018 08:14:07 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id e7-v6sm27990271wru.46.2018.09.21.08.14.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 08:14:06 -0700 (PDT) From: Andrey Konovalov To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan , Andrey Konovalov Subject: [PATCH v9 12/20] kasan, arm64: enable top byte ignore for the kernel Date: Fri, 21 Sep 2018 17:13:34 +0200 Message-Id: <7edbd2d0b0c6f0b7a2b33e3d6da2f14b4b63b8ff.1537542735.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.444.g18242da7ef-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tag-based KASAN uses the Top Byte Ignore feature of arm64 CPUs to store a pointer tag in the top byte of each pointer. This commit enables the TCR_TBI1 bit, which enables Top Byte Ignore for the kernel, when tag-based KASAN is used. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/pgtable-hwdef.h | 1 + arch/arm64/mm/proc.S | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h index fd208eac9f2a..483aceedad76 100644 --- a/arch/arm64/include/asm/pgtable-hwdef.h +++ b/arch/arm64/include/asm/pgtable-hwdef.h @@ -289,6 +289,7 @@ #define TCR_A1 (UL(1) << 22) #define TCR_ASID16 (UL(1) << 36) #define TCR_TBI0 (UL(1) << 37) +#define TCR_TBI1 (UL(1) << 38) #define TCR_HA (UL(1) << 39) #define TCR_HD (UL(1) << 40) #define TCR_NFD1 (UL(1) << 54) diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 03646e6a2ef4..b2b44dbdb063 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -47,6 +47,12 @@ /* PTWs cacheable, inner/outer WBWA */ #define TCR_CACHE_FLAGS TCR_IRGN_WBWA | TCR_ORGN_WBWA +#ifdef CONFIG_KASAN_SW_TAGS +#define TCR_KASAN_FLAGS TCR_TBI1 +#else +#define TCR_KASAN_FLAGS 0 +#endif + #define MAIR(attr, mt) ((attr) << ((mt) * 8)) /* @@ -440,7 +446,7 @@ ENTRY(__cpu_setup) */ ldr x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \ TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \ - TCR_TBI0 | TCR_A1 + TCR_TBI0 | TCR_A1 | TCR_KASAN_FLAGS tcr_set_idmap_t0sz x10, x9 /* -- 2.19.0.444.g18242da7ef-goog