Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp999334lqd; Thu, 25 Apr 2024 03:06:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTDJU0SOonZcCjSodVjt04uJJw83X1BlD2FETHJm4hj/FCUlrofx7pHb2aWI7HUo2t/i0gdSIwrjewa3MNvVYHf/5CpiyL04w/5j3V0w== X-Google-Smtp-Source: AGHT+IGt2UtsbJ4ZEvBByTX5k0FK5jmgm46RituWpLIrc09OJIRQ+oY6QykqTguXNkIOHs1mU1cR X-Received: by 2002:a17:90b:3ec4:b0:2ac:88e4:2dd with SMTP id rm4-20020a17090b3ec400b002ac88e402ddmr5301220pjb.0.1714039618719; Thu, 25 Apr 2024 03:06:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714039618; cv=pass; d=google.com; s=arc-20160816; b=rVrfdBl6MgMaqIt+mIvZX37l91lYXGqkiH+F8pvkWSuxiVYR605H771O8vRRpDTbHd Pko9f5mqaIcRzpOPrlOB9zUkIkthRWBNnCmKeQ11kYbNYuLMF75jZHhkvIrxf5Yri4Gg eXxSN8AJx8ORa+pKmrF7OWaXx32AOMnPK3E/GeCA2Gi9lCbOnZoFG1dKn27vBAVEYUdR gXEcNvgKubMWZ/RgZ+8Hh5R3lFMo+lf5/ImK2MqHQWlsF9101rBLMUMlg6JBsmWhA6kE daOCtb0SQQRE12vyMtwYRxXH7o+xFPe5Lwn4fo+sL7+i4ojQsxqqwlsoDRwLAzNhQWt/ cdRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uqT75ILAb+wFvlIguVkiSmYBoQIWQKOiZ3Xjg0k4Etc=; fh=a65zxfxMZNk6ZYoL66cgdUvxE8f+AqXFtq/IK/LF5zo=; b=niO6hkJadIiaGz5h+S4egHx5DcTiX2aVC2Dy6cOxQJx1/lsWF46QLsKpk5fv0yTqzr dfjaHo7lHSsR8/vD2ceLdO2w8QfKnmLQ3gdHrGii+urtgBx3bsHc2+m+SVfJtMzR9Seb 6xxDve1DdFUjC2dyGsQkRaeaa4Cy/tCzZzPE+khCWfvWhAZzv0u9iQXjIYiXp07gsqA7 qlMFqryEifWigTE1Uz3pWjvVncvHtrDrgY+v67BAMwcm3Y7uXonOSdvmiMKHsL3Zsuck PC67kd10AkAQ8i7g36Hfl9oIZIX21uHLjbcaPtkqXH6s50Wn/9RGfONSbCrSGTEpioIh 0svA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JNtEPkRP; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-158359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bw11-20020a17090af60b00b002ab6ccac659si13053477pjb.13.2024.04.25.03.06.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 03:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JNtEPkRP; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-158359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 71ECD2841B5 for ; Thu, 25 Apr 2024 10:06:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10EF2128828; Thu, 25 Apr 2024 10:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JNtEPkRP" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B570F128804 for ; Thu, 25 Apr 2024 10:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714039504; cv=none; b=qv/1LUvvxxTgEzJ9NE9Hc9Flr4dubf7XXxCV0nWz5nyylVnox5V7vDxMF2nyRKqgA83etMro2dDPbwCKQH9OVgfI0SI7Waes6cFmV8XrDJZKyrGnDHnx8x6IAG/M0H0wN5Uf3Eji3wRxIaLHf0EPVCYfFklG2wM536+H7ZGTqNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714039504; c=relaxed/simple; bh=WwCFGkuEUhfYpOXGOtlQ0bc+aePAZJhfQPq/y/fFe+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r3c25SdbyC+ueYNZcgPLB6zqSWNFVfBy8RwqR8LOZA5o8iJG7yx+TVG8DFoVooIKf4HhmJnmjGPHFL5hki90TPRKHfJ49KPLI4g7b+J3H4ZTfCZUCwr6Hm9CdQyvFi19K8XO3CmthXDTyC9U115L6IR7xjBBYSQj6mdCrZSFXP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JNtEPkRP; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714039501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uqT75ILAb+wFvlIguVkiSmYBoQIWQKOiZ3Xjg0k4Etc=; b=JNtEPkRPNEw5irNYq+Ch112LoJd7dwmCiaNf5ptsF+FpQUR8MEzrhmbrmOm2zK1R5ukFye BCIcyzwdOmfuqAWvd46Mbxb7IqW+yoyRxx6TzUMqTElRIi6f8ls1L+SuMC6NV8kNIqCBPY HIqWDd3Rxnsou/DeKUwqfSXRnHh0pv8= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-yxb7iLx5MuG_zMVM2rlU4g-1; Thu, 25 Apr 2024 06:05:00 -0400 X-MC-Unique: yxb7iLx5MuG_zMVM2rlU4g-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2a537ab9d7eso940995a91.1 for ; Thu, 25 Apr 2024 03:05:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714039498; x=1714644298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uqT75ILAb+wFvlIguVkiSmYBoQIWQKOiZ3Xjg0k4Etc=; b=RFcKm8v7dTqg+8SXfOX8XcKzIvhN4UV3+alo3+scRrG06B1seJdposaa5GpY+VC9ZN GZwUnXQSSaErv7MCZMQgwICDHrgIRI2G2nIW7qjh49ehZfQ9XcW1kBdhAHsEjka6sxV/ F/hZmSofl6wU3vn4X+QalGO8lzmUhuwVU8+0iT9ORzyqm7C+8q0FM2Cw6YFpVEN3yYlJ OS/cjwRxqATNveO/jKByKaIxuMcewK6tFLXO9cWucVxQRj/wH1IX3M0qrzimSmZwYtrM nGcVYPhsRjQowHZZuGIXC4Fd5tRX2Vm6FsgDEtnFF2Enew3v/lODATVtcP+7dwLkEuv6 WLkg== X-Forwarded-Encrypted: i=1; AJvYcCVALvQp3O8MzSem54grB3kFg/p99nDFhXNO1wDsF3LLE+5m96MnHerWBdcW+E84kSZ9tg8/ETXffSG2eRwUXwrDltliQs30tkz8I09h X-Gm-Message-State: AOJu0YzF1lJwcODAhnpp+BofkbVX2dim5anlgI4nwFoMyIB+xUo6kiVJ 6xn0ScB5xEHXSwlELbODQOoz53KzB+LOs1i80mRNBLBNHNguh8+HAcAKbNLiGUj4x6EmpEKU82b 73b0W0YdNK2wO/NG/kHXSRYVq+k87JceJ4+5Xepj8CNV2IApiJc3JRHr+L/iZFbeQApQzc7dAqx gb4Q== X-Received: by 2002:a17:90b:33ce:b0:2a0:215f:dc9c with SMTP id lk14-20020a17090b33ce00b002a0215fdc9cmr5203413pjb.35.1714039498204; Thu, 25 Apr 2024 03:04:58 -0700 (PDT) X-Received: by 2002:a17:90b:33ce:b0:2a0:215f:dc9c with SMTP id lk14-20020a17090b33ce00b002a0215fdc9cmr5203372pjb.35.1714039497570; Thu, 25 Apr 2024 03:04:57 -0700 (PDT) Received: from localhost ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id cn19-20020a17090af09300b002a2b06ce909sm14227786pjb.17.2024.04.25.03.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 03:04:56 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: Ondrej Kozina , Milan Broz , Thomas Staudt , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Kairui Song , dm-devel@redhat.com, Jan Pazdziora , Pingfan Liu , Baoquan He , Dave Young , linux-kernel@vger.kernel.org, x86@kernel.org, Dave Hansen , Vitaly Kuznetsov , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v3 6/7] x86/crash: pass dm crypt keys to kdump kernel Date: Thu, 25 Apr 2024 18:04:30 +0800 Message-ID: <20240425100434.198925-7-coxu@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240425100434.198925-1-coxu@redhat.com> References: <20240425100434.198925-1-coxu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 1st kernel will build up the kernel command parameter dmcryptkeys as similar to elfcorehdr to pass the memory address of the stored info of dm crypt key to kdump kernel. Signed-off-by: Coiby Xu --- arch/x86/kernel/crash.c | 15 ++++++++++++++- arch/x86/kernel/kexec-bzimage64.c | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index e74d0c4286c1..d852f9c99f0e 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -266,6 +266,7 @@ static int memmap_exclude_ranges(struct kimage *image, struct crash_mem *cmem, unsigned long long mend) { unsigned long start, end; + int r; cmem->ranges[0].start = mstart; cmem->ranges[0].end = mend; @@ -274,7 +275,19 @@ static int memmap_exclude_ranges(struct kimage *image, struct crash_mem *cmem, /* Exclude elf header region */ start = image->elf_load_addr; end = start + image->elf_headers_sz - 1; - return crash_exclude_mem_range(cmem, start, end); + r = crash_exclude_mem_range(cmem, start, end); + + if (r) + return r; + + /* Exclude dm crypt keys region */ + if (image->dm_crypt_keys_addr) { + start = image->dm_crypt_keys_addr; + end = start + image->dm_crypt_keys_sz - 1; + return crash_exclude_mem_range(cmem, start, end); + } + + return r; } /* Prepare memory map for crash dump kernel */ diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c index 68530fad05f7..9c94428927bd 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -76,6 +76,10 @@ static int setup_cmdline(struct kimage *image, struct boot_params *params, if (image->type == KEXEC_TYPE_CRASH) { len = sprintf(cmdline_ptr, "elfcorehdr=0x%lx ", image->elf_load_addr); + + if (image->dm_crypt_keys_addr != 0) + len += sprintf(cmdline_ptr + len, + "dmcryptkeys=0x%lx ", image->dm_crypt_keys_addr); } memcpy(cmdline_ptr + len, cmdline, cmdline_len); cmdline_len += len; @@ -441,6 +445,9 @@ static void *bzImage64_load(struct kimage *image, char *kernel, ret = crash_load_segments(image); if (ret) return ERR_PTR(ret); + ret = crash_load_dm_crypt_keys(image); + if (ret) + pr_debug("Either no dm crypt key or error to retrieve the dm crypt key\n"); } #endif -- 2.44.0