From 03cf00ebf89e405bbd8a6b0112cc4c99ed4f4d1e Mon Sep 17 00:00:00 2001 From: Rob Gardner Date: Wed, 19 Apr 2017 11:21:13 -0600 Subject: [PATCH] sparc64: Disable DAX flow control Orabug: 25997202 The flow control feature of DAX only works for output buffers and it doesn't appear to be possible to calculate the exact size in bytes of an input buffer. So we have no way to bound the amount of data that DAX reads as input. This has correctness and security implications, so until we figure out something better to do, the temporary workaround is to disable flow control completely and fall back to 4Mb virtual page backed dax_alloc memory, which will allow page boundaries to limit the size of all buffers. A new module parameter "flow_enable" is provided to allow this decision to be reverted at module load time if needed. Signed-off-by: Rob Gardner Reviewed-by: Jonathan Helman Reviewed-by: Sanath Kumar Signed-off-by: Allen Pais --- arch/sparc/dax/dax_main.c | 10 ++++++++-- arch/sparc/dax/dax_mm.c | 6 +----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/sparc/dax/dax_main.c b/arch/sparc/dax/dax_main.c index 87c345dffdf8..078ea1ce9265 100644 --- a/arch/sparc/dax/dax_main.c +++ b/arch/sparc/dax/dax_main.c @@ -50,6 +50,9 @@ module_param(force, int, 0644); MODULE_PARM_DESC(force, "Forces module loading if no device present"); module_param(dax_debug, int, 0644); MODULE_PARM_DESC(dax_debug, "Debug flags"); +static int flow_enable = 0; +module_param(flow_enable, int, 0644); +MODULE_PARM_DESC(flow_enable, "Enables flow control if hardware supports it"); static const struct file_operations dax_fops = { .owner = THIS_MODULE, @@ -163,8 +166,11 @@ static int __init dax_attach(void) * MD does not report it in old versions of HV, we need to explicitly * check for flow control feature. */ - if ((dax_type == DAX1) && !dax_has_flow_ctl_numa()) { - dax_dbg("Flow control disabled, dax_alloc restricted to 4M"); + if (!flow_enable) { + dax_dbg("Flow control disabled by software, dax_alloc restricted to 4M"); + dax_no_flow_ctl = true; + } else if ((dax_type == DAX1) && !dax_has_flow_ctl_numa()) { + dax_dbg("Flow control disabled by hardware, dax_alloc restricted to 4M"); dax_no_flow_ctl = true; } else { dax_dbg("Flow control enabled"); diff --git a/arch/sparc/dax/dax_mm.c b/arch/sparc/dax/dax_mm.c index 480c07b949cc..890e2c4d8e52 100644 --- a/arch/sparc/dax/dax_mm.c +++ b/arch/sparc/dax/dax_mm.c @@ -249,11 +249,7 @@ void dax_map_segment(struct dax_ctx *dax_ctx, union ccb *ccb, size_t ccb_len) } if (hdr->at_src0 == CCB_AT_VA_ALT) { - access = (struct ccb_data_acc_ctl *) - &ccbp->dwords[QUERY_DWORD_DAC]; - /* size in bytes */ - size = DAX_IN_SIZE_FROM_CCB(access->input_cnt); - if (dax_map_segment_common(size, &ccb_addr_type, "src0", + if (dax_map_segment_common(0, &ccb_addr_type, "src0", QUERY_DWORD_INPUT, ccbp, dax_ctx) == 0) hdr->at_src0 = ccb_addr_type; -- 2.50.1