Index: sys/dev/mem/memdev.c =================================================================== --- sys/dev/mem/memdev.c +++ sys/dev/mem/memdev.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -99,6 +100,8 @@ vm_map_entry_t entry; struct mem_extract *me; int fd, error; + struct diocskerneldump_arg *conf; + uint8_t *encryptedkey; error = 0; switch (cmd) { @@ -125,6 +128,36 @@ fd = *(int *)data; error = livedump_start(fd); break; + case DIOCSKERNELDUMP: + encryptedkey = NULL; + conf = (void *)data; + if (conf->kda_index == KDA_REMOVE || + conf->kda_index == KDA_REMOVE_DEV || + conf->kda_index == KDA_REMOVE_ALL) { + /* Nothing to do. */ + return (0); + } + if (conf->kda_encryption != KERNELDUMP_ENC_NONE) { + if (conf->kda_encryptedkeysize <= 0 || + conf->kda_encryptedkeysize > + KERNELDUMP_ENCKEY_MAX_SIZE) { + error = EINVAL; + break; + } + encryptedkey = malloc(conf->kda_encryptedkeysize, + M_TEMP, M_WAITOK); + error = copyin(conf->kda_encryptedkey, encryptedkey, + conf->kda_encryptedkeysize); + if (error != 0) { + free(encryptedkey, M_TEMP); + break; + } + conf->kda_encryptedkey = encryptedkey; + } + + error = livedump_configure(conf); + free(encryptedkey, M_TEMP); + break; default: error = memioctl_md(dev, cmd, data, flags, td); break;