Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4551759ybb; Tue, 24 Mar 2020 00:31:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs6vIwiGhZVLQ1nPRWC34TYuM6+UrLIr72o6MQ6zWn2ZrTX3naVvu47YMpjNd8rifIblYnt X-Received: by 2002:a05:6830:1003:: with SMTP id a3mr2584976otp.128.1585035094091; Tue, 24 Mar 2020 00:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585035094; cv=none; d=google.com; s=arc-20160816; b=prMYZKi2Abox3mh1jcmnsAFu4j4/0D/mVqoHpos9PP32BhkeG9qGufjU8DN+ivYLiZ e9rlZOtKaIALMqNQdUscPMoOM/xSF2UHyWzX/kpBEJ0+w2hzCHSLL5MB0Kq8SBjGxAdX iChhiQVER3W7iqvzKVxDv4F65/HuQexE4cmjb3R1IAHblhQgkPVVVGG2OzIXokmqGZhn 6ALjnxoEmggcq/ICXbKSNeDFzbhTRrSB+BW+e9YPneX6SAmgj1zLTYayPSHHeK6tgiyA /kwwX7TTGOABHqTH7PeAw6G61GS3Uet8nZPU8hBXhtuKMwtTtnC6w93OZqTsJDwkPcCb jxyg== 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=rI7k74kFCx75JJFZ6P5OAIxYXRc1E3R4Ch5Nvkd/PLg=; b=j8/7L9eHPhoSKXWag1f/lH0QK8gztQBlelbZK1X1tCNxwTLpKaIdgU9eddvdeCHgL8 SV4oZ73UeOxMUnuR6ZNhG+IysJ+WrLMVV/9opAVZfvNTN2MyCBD7FwNo/vTpNmXCNAeI XbLzieScQBpypirtmI+9zL7l2YbTj6fbR2FNMkhEwdWAdjp6BgzWrLPj00DH12jj8J8U 4P3sAUCvxQMsAqBcX1jMB8WFqSpFD6k0Ap5YX+hLndp2ZputJluUNUFRJzOXGwgiXRvM Gz+vl544jPtKrOyu/3P4sAs/XfoHXQhHA1jp3bi8BGQQihnZYfgdYdzO6G0KNFzv8R7E J+ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=dEevPmr8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si3258065oiq.222.2020.03.24.00.31.21; Tue, 24 Mar 2020 00:31:34 -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=@sifive.com header.s=google header.b=dEevPmr8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727469AbgCXHbC (ORCPT + 99 others); Tue, 24 Mar 2020 03:31:02 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35817 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbgCXHbA (ORCPT ); Tue, 24 Mar 2020 03:31:00 -0400 Received: by mail-pl1-f196.google.com with SMTP id g6so7073182plt.2 for ; Tue, 24 Mar 2020 00:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rI7k74kFCx75JJFZ6P5OAIxYXRc1E3R4Ch5Nvkd/PLg=; b=dEevPmr87gMs/zwZYhDr7kBAchZIIxA4j5XE/SWfIF4tf1bkYVtCjmF3HsMceLOm/f yMUMX1CJJOm8dr2xxEoJWUbfGXvxESvk3D0nxnwpGXEjuBCmUsgS16u0WGb8owp6HQw4 IEug9xf/t27S0CWLebeXEEqDTvoaWjbkL720nZutV1M8l8cdL588L5zelE+ZOKxiTCS+ vbMGHNscXpKxbnk87V5VOYQz2ImoBQUmms6OABHlwE0fY7e3BGB4yTliJXWw0s0KJMwR 34bOJFpvs9St2+5ZOCOEN7S9LcoDAIhATu3a1S1NGHc8lMXQbEUh2u2WKje+RTRJjySE 088Q== 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=rI7k74kFCx75JJFZ6P5OAIxYXRc1E3R4Ch5Nvkd/PLg=; b=TQ3pQ6qWLMid2yiz0BoRuN7W/Hi/hv94eQ8w360fcf7Z49JMhXayMwjdl/nN6wy80Q x+GW1zlXwbQsw9Uje83+zdtcu+6YkVDTQ2U1FC92QLrryMvTxN+erBSox8xeDSv/hdjX V8HQgkzEtcjSLDFfQsiPDkc9FbVWASFyjQjOLzhQ1AB+4N6gyQDsJWEiyJmbZpgVw9X6 obAJIn0qVW8o+qrTMysACDK6h7oiHAV287xHauBlFu5Fzk+avy9aadd3kSwlslWBxaEJ 5Y087iMO8zaPE6agpLv/ZuCsNOOIP4ck4Zs96c+Hcd9e0qkroqTvHn9r3Sb5FsEf5n7M D67A== X-Gm-Message-State: ANhLgQ0Yca20gPdZixr7hJxUK299ZnZQN+XwnLTdNNsK3pywbmRA5rvT fL6ngD0iJtYCqYKJaXUkBc/qsT92Z0M= X-Received: by 2002:a17:90a:3606:: with SMTP id s6mr3821002pjb.195.1585035058819; Tue, 24 Mar 2020 00:30:58 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id i187sm15124648pfg.33.2020.03.24.00.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 00:30:58 -0700 (PDT) From: Zong Li To: palmer@dabbelt.com, paul.walmsley@sifive.com, alex@ghiti.fr, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [PATCH RFC 1/8] riscv/kaslr: add interface to get kaslr offset Date: Tue, 24 Mar 2020 15:30:46 +0800 Message-Id: X-Mailer: git-send-email 2.25.2 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 Add interface to get the random offset. Signed-off-by: Zong Li --- arch/riscv/include/asm/page.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index 92848e172a40..e2c2020f0a8d 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -101,6 +101,11 @@ extern unsigned long kernel_virt_addr; extern unsigned long max_low_pfn; extern unsigned long min_low_pfn; +static inline unsigned long get_kaslr_offset(void) +{ + return kernel_virt_addr - PAGE_OFFSET; +} + #define __pa_to_va_nodebug(x) ((void *)((unsigned long) (x) + va_pa_offset)) #define __va_to_pa_nodebug(x) ((unsigned long)(x) - va_pa_offset) -- 2.25.1